diff --git a/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.cpp.patch b/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.cpp.patch deleted file mode 100644 index 769a50fe7..000000000 --- a/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp -+++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.cpp -@@ -16,7 +16,7 @@ - - #include - #include --#include -+#include - #include - #include - diff --git a/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.h.patch b/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.h.patch deleted file mode 100644 index 802a31e52..000000000 --- a/packages/fex/External-FEXCore-Source-Interface-Core-Dispatcher-Dispatcher.h.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h -+++ b/External/FEXCore/Source/Interface/Core/Dispatcher/Dispatcher.h -@@ -5,7 +5,7 @@ - #include "Interface/Context/Context.h" - #include "Interface/Core/ArchHelpers/MContext.h" - --#include -+#include - #include - #include - #include diff --git a/packages/fex/External-FEXCore-Source-Interface-Core-Interpreter-InterpreterCore.cpp.patch b/packages/fex/External-FEXCore-Source-Interface-Core-Interpreter-InterpreterCore.cpp.patch deleted file mode 100644 index a5e5d0a4e..000000000 --- a/packages/fex/External-FEXCore-Source-Interface-Core-Interpreter-InterpreterCore.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/External/FEXCore/Source/Interface/Core/Interpreter/InterpreterCore.cpp -+++ b/External/FEXCore/Source/Interface/Core/Interpreter/InterpreterCore.cpp -@@ -11,7 +11,7 @@ - #include - - #include --#include -+#include - #include - #include - #include diff --git a/packages/fex/External-FEXCore-Source-Utils-Allocator-64BitAllocator.cpp.patch b/packages/fex/External-FEXCore-Source-Utils-Allocator-64BitAllocator.cpp.patch deleted file mode 100644 index e8817d767..000000000 --- a/packages/fex/External-FEXCore-Source-Utils-Allocator-64BitAllocator.cpp.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp -+++ b/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp -@@ -23,7 +23,6 @@ - #include - - static constexpr uint64_t PAGE_SHIFT = 12; --static constexpr uint64_t PAGE_MASK = (1 << PAGE_SHIFT) - 1; - - namespace Alloc::OSAllocator { - class OSAllocator_64Bit final : public Alloc::HostAllocator { -@@ -37,7 +36,6 @@ - int Munmap(void *addr, size_t length) override; - - private: -- constexpr static uint64_t PAGE_SIZE = 4096; - // Upper bound is the maximum virtual address space of the host processor - uintptr_t UPPER_BOUND = (1ULL << 57); - diff --git a/packages/fex/External-FEXCore-Source-Utils-Allocator-HostAllocator.h.patch b/packages/fex/External-FEXCore-Source-Utils-Allocator-HostAllocator.h.patch deleted file mode 100644 index 78a2ed94a..000000000 --- a/packages/fex/External-FEXCore-Source-Utils-Allocator-HostAllocator.h.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/External/FEXCore/Source/Utils/Allocator/HostAllocator.h -+++ b/External/FEXCore/Source/Utils/Allocator/HostAllocator.h -@@ -5,8 +5,6 @@ - #include - #include - --constexpr static uint64_t PAGE_SIZE = 4096; -- - namespace Alloc { - // HostAllocator is just a page pased slab allocator - // Similar to mmap and munmap only mapping at the page level diff --git a/packages/fex/External-FEXCore-Source-Utils-Allocator-IntrusiveArenaAllocator.h.patch b/packages/fex/External-FEXCore-Source-Utils-Allocator-IntrusiveArenaAllocator.h.patch deleted file mode 100644 index cbd71b15d..000000000 --- a/packages/fex/External-FEXCore-Source-Utils-Allocator-IntrusiveArenaAllocator.h.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h -+++ b/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h -@@ -7,10 +7,15 @@ - - #include - #include --#include -+#include -+#include - #include - #include - -+namespace std { -+ namespace pmr = experimental::pmr; -+} -+ - namespace Alloc { - class ForwardOnlyIntrusiveArenaAllocator final : public std::pmr::memory_resource { - public: diff --git a/packages/fex/External-FEXCore-include-FEXCore-Core-SignalDelegator.h.patch b/packages/fex/External-FEXCore-include-FEXCore-Core-SignalDelegator.h.patch deleted file mode 100644 index 5a6915d36..000000000 --- a/packages/fex/External-FEXCore-include-FEXCore-Core-SignalDelegator.h.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/External/FEXCore/include/FEXCore/Core/SignalDelegator.h -+++ b/External/FEXCore/include/FEXCore/Core/SignalDelegator.h -@@ -3,8 +3,8 @@ - #include - - #include --#include --#include -+#include -+#include - #include - #include - #include diff --git a/packages/fex/External-FEXCore-include-FEXCore-Core-UContext.h.patch b/packages/fex/External-FEXCore-include-FEXCore-Core-UContext.h.patch deleted file mode 100644 index 17956c07f..000000000 --- a/packages/fex/External-FEXCore-include-FEXCore-Core-UContext.h.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/External/FEXCore/include/FEXCore/Core/UContext.h -+++ b/External/FEXCore/include/FEXCore/Core/UContext.h -@@ -163,12 +163,14 @@ - val.si_errno = si_errno; - val.si_code = si_code; - -+#ifndef __ANDROID__ - // Host siginfo has a pad member that is set to zeros - val.__pad0 = 0; - - // Copy over the union - // The union is different sizes on 64-bit versus 32-bit - memcpy(val._sifields._pad, _sifields.pad, std::min(sizeof(val._sifields._pad), sizeof(_sifields.pad))); -+#endif - - return val; - } diff --git a/packages/fex/Source-Common-SocketLogging.cpp.patch b/packages/fex/Source-Common-SocketLogging.cpp.patch deleted file mode 100644 index c0057d8b6..000000000 --- a/packages/fex/Source-Common-SocketLogging.cpp.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/Source/Common/SocketLogging.cpp -+++ b/Source/Common/SocketLogging.cpp -@@ -7,6 +7,7 @@ - #include - #include - #include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-LinuxAllocator.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-LinuxAllocator.cpp.patch deleted file mode 100644 index ade329e7a..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-LinuxAllocator.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp -+++ b/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp -@@ -19,8 +19,6 @@ - class MemAllocator32Bit final : public FEX::HLE::MemAllocator { - private: - static constexpr uint64_t PAGE_SHIFT = 12; -- static constexpr uint64_t PAGE_SIZE = 1 << PAGE_SHIFT; -- static constexpr uint64_t PAGE_MASK = (1 << PAGE_SHIFT) - 1; - static constexpr uint64_t BASE_KEY = 16; - const uint64_t TOP_KEY = 0xFFFF'F000ULL >> PAGE_SHIFT; - const uint64_t TOP_KEY32BIT = 0x1F'F000ULL >> PAGE_SHIFT; diff --git a/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.cpp.patch deleted file mode 100644 index a011d5295..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.cpp.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/SignalDelegator.cpp -+++ b/Source/Tests/LinuxSyscalls/SignalDelegator.cpp -@@ -24,7 +24,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include -@@ -42,7 +42,6 @@ - } - #endif - -- constexpr static uint32_t SS_AUTODISARM = (1U << 31); - constexpr static uint32_t X86_MINSIGSTKSZ = 0x2000U; - - // We can only have one delegator per process diff --git a/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.h.patch b/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.h.patch deleted file mode 100644 index 45d175d1b..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-SignalDelegator.h.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/SignalDelegator.h -+++ b/Source/Tests/LinuxSyscalls/SignalDelegator.h -@@ -9,8 +9,8 @@ - - #include - #include --#include --#include -+#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FD.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FD.cpp.patch deleted file mode 100644 index c220511c7..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FD.cpp.patch +++ /dev/null @@ -1,46 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/FD.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/FD.cpp -@@ -257,11 +257,13 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30 - REGISTER_SYSCALL_IMPL_PASS(memfd_create, [](FEXCore::Core::CpuStateFrame *Frame, const char *name, uint32_t flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::memfd_create(name, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL(statx, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, int flags, uint32_t mask, struct statx *statxbuf) -> uint64_t { - // Flags don't need remapped -@@ -269,6 +271,7 @@ - SYSCALL_ERRNO(); - }); - -+#ifndef __ANDROID__ - REGISTER_SYSCALL_IMPL_PASS(name_to_handle_at, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, struct file_handle *handle, int *mount_id, int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::name_to_handle_at(dirfd, pathname, handle, mount_id, flags); -@@ -280,6 +283,7 @@ - uint64_t Result = ::open_by_handle_at(mount_fd, handle, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_PASS(eventfd2, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int count, int flags) -> uint64_t { - // Flags don't need remapped -@@ -287,11 +291,13 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_PASS(copy_file_range, [](FEXCore::Core::CpuStateFrame *Frame, int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::copy_file_range(fd_in, off_in, fd_out, off_out, len, flags); - SYSCALL_ERRNO(); - }); -+#endif - - if (Handler->IsHostKernelVersionAtLeast(5, 3, 0)) { - REGISTER_SYSCALL_IMPL_PASS(pidfd_open, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, unsigned int flags) -> uint64_t { diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FS.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FS.cpp.patch deleted file mode 100644 index dd4c06726..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-FS.cpp.patch +++ /dev/null @@ -1,40 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/FS.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/FS.cpp -@@ -10,7 +10,7 @@ - - #include - #include --#include -+#include - #include - #include - #include -@@ -149,10 +149,12 @@ - }); - - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 28 - REGISTER_SYSCALL_IMPL_PASS(syncfs, [](FEXCore::Core::CpuStateFrame *Frame, int fd) -> uint64_t { - uint64_t Result = ::syncfs(fd); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_PASS(setxattr, [](FEXCore::Core::CpuStateFrame *Frame, const char *path, const char *name, const void *value, size_t size, int flags) -> uint64_t { - uint64_t Result = ::setxattr(path, name, value, size, flags); -@@ -214,6 +216,7 @@ - SYSCALL_ERRNO(); - }); - -+#ifndef __ANDROID__ - REGISTER_SYSCALL_IMPL_PASS(fanotify_init, [](FEXCore::Core::CpuStateFrame *Frame, unsigned int flags, unsigned int event_f_flags) -> uint64_t { - uint64_t Result = ::fanotify_init(flags, event_f_flags); - SYSCALL_ERRNO(); -@@ -223,6 +226,7 @@ - uint64_t Result = ::fanotify_mark(fanotify_fd, flags, mask, dirfd, pathname); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_PASS(pivot_root, [](FEXCore::Core::CpuStateFrame *Frame, const char *new_root, const char *put_old) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(pivot_root), new_root, put_old); diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Info.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Info.cpp.patch deleted file mode 100644 index b5bb095da..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Info.cpp.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Info.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Info.cpp -@@ -63,10 +63,12 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 28 - REGISTER_SYSCALL_IMPL_PASS(getrandom, [](FEXCore::Core::CpuStateFrame *Frame, void *buf, size_t buflen, unsigned int flags) -> uint64_t { - uint64_t Result = ::getrandom(buf, buflen, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_PASS(capget, [](FEXCore::Core::CpuStateFrame *Frame, cap_user_header_t hdrp, cap_user_data_t datap) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(capget), hdrp, datap); diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Key.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Key.cpp.patch deleted file mode 100644 index d4e365f9c..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Key.cpp.patch +++ /dev/null @@ -1,17 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Key.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Key.cpp -@@ -30,6 +30,7 @@ - SYSCALL_ERRNO(); - }); - -+#ifndef __ANDROID__ - REGISTER_SYSCALL_IMPL_PASS(pkey_mprotect, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t len, int prot, int pkey) -> uint64_t { - // Added in Linux 4.9 - uint64_t Result = ::pkey_mprotect(addr, len, prot, pkey); -@@ -47,5 +48,6 @@ - uint64_t Result = ::pkey_free(pkey); - SYSCALL_ERRNO(); - }); -+#endif - } - } diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Memory.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Memory.cpp.patch deleted file mode 100644 index cab79e31e..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Memory.cpp.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Memory.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Memory.cpp -@@ -46,16 +46,20 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30 - REGISTER_SYSCALL_IMPL_PASS(mlock2, [](FEXCore::Core::CpuStateFrame *Frame, const void *addr, size_t len, int flags) -> uint64_t { - uint64_t Result = ::mlock2(addr, len, flags); - SYSCALL_ERRNO(); - }); -+#endif - -+#ifndef __ANDROID__ - REGISTER_SYSCALL_IMPL_PASS(remap_file_pages, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, size_t size, int prot, size_t pgoff, int flags) -> uint64_t { - // This syscall is deprecated, not sure when it will end up being removed - uint64_t Result = ::remap_file_pages(addr, size, prot, pgoff, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_PASS(mbind, [](FEXCore::Core::CpuStateFrame *Frame, void *addr, unsigned long len, int mode, const unsigned long *nodemask, unsigned long maxnode, unsigned flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(mbind), addr, len, mode, nodemask, maxnode, flags); diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Msg.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Msg.cpp.patch deleted file mode 100644 index 620decc89..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Msg.cpp.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Msg.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Msg.cpp -@@ -8,7 +8,7 @@ - #include "Tests/LinuxSyscalls/x64/Syscalls.h" - #include "Tests/LinuxSyscalls/x32/Syscalls.h" - --#include -+#include - #include - #include - #include -@@ -17,6 +17,7 @@ - - namespace FEX::HLE { - void RegisterMsg() { -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_PASS(msgget, [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int msgflg) -> uint64_t { - uint64_t Result = ::msgget(key, msgflg); - SYSCALL_ERRNO(); -@@ -40,6 +41,7 @@ - uint64_t Result = ::msgctl(msqid, cmd, buf); - SYSCALL_ERRNO(); - }); -+#endif - - // last two parameters are optional - REGISTER_SYSCALL_IMPL_PASS(mq_unlink, [](FEXCore::Core::CpuStateFrame *Frame, const char *name) -> uint64_t { diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Semaphore.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Semaphore.cpp.patch deleted file mode 100644 index a5b7033a7..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Semaphore.cpp.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Semaphore.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Semaphore.cpp -@@ -10,14 +10,16 @@ - - #include - #include --#include -+#include - - namespace FEX::HLE { - void RegisterSemaphore() { -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_PASS(semget, [](FEXCore::Core::CpuStateFrame *Frame, key_t key, int nsems, int semflg) -> uint64_t { - uint64_t Result = ::semget(key, nsems, semflg); - SYSCALL_ERRNO(); - }); -+#endif - - } - } diff --git a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Thread.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Thread.cpp.patch deleted file mode 100644 index f2dae2d96..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-Syscalls-Thread.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/Syscalls/Thread.cpp -+++ b/Source/Tests/LinuxSyscalls/Syscalls/Thread.cpp -@@ -465,7 +465,7 @@ - }); - - REGISTER_SYSCALL_IMPL_PASS(prlimit64, [](FEXCore::Core::CpuStateFrame *Frame, pid_t pid, int resource, const struct rlimit *new_limit, struct rlimit *old_limit) -> uint64_t { -- uint64_t Result = ::prlimit(pid, (enum __rlimit_resource)(resource), new_limit, old_limit); -+ uint64_t Result = ::prlimit(pid, resource, new_limit, old_limit); - SYSCALL_ERRNO(); - }); - diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-FD.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-FD.cpp.patch deleted file mode 100644 index 1bc7e75ce..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-FD.cpp.patch +++ /dev/null @@ -1,27 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/FD.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/FD.cpp -@@ -17,7 +17,7 @@ - #include - - #include --#include -+#include - #include - #include - #include -@@ -988,6 +988,7 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X32(sync_file_range, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, - uint32_t offset_low, -@@ -1007,6 +1008,7 @@ - uint64_t Result = ::sync_file_range(fd, Offset, Len, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_X32(fallocate, [](FEXCore::Core::CpuStateFrame *Frame, - int fd, diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Info.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Info.cpp.patch deleted file mode 100644 index 913674a97..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Info.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Info.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Info.cpp -@@ -10,7 +10,7 @@ - - #include - #include --#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Memory.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Memory.cpp.patch deleted file mode 100644 index 1cc9677a9..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Memory.cpp.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Memory.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Memory.cpp -@@ -83,10 +83,12 @@ - mremap(old_address, old_size, new_size, flags, new_address)); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 30 - REGISTER_SYSCALL_IMPL_X32(mlockall, [](FEXCore::Core::CpuStateFrame *Frame, int flags) -> uint64_t { - uint64_t Result = ::mlock2(reinterpret_cast(0x1'0000), 0x1'0000'0000ULL - 0x1'0000, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_X32(munlockall, [](FEXCore::Core::CpuStateFrame *Frame) -> uint64_t { - uint64_t Result = ::munlock(reinterpret_cast(0x1'0000), 0x1'0000'0000ULL - 0x1'0000); diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Msg.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Msg.cpp.patch deleted file mode 100644 index e5a54153e..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Msg.cpp.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Msg.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Msg.cpp -@@ -10,12 +10,16 @@ - - #include "Tests/LinuxSyscalls/x64/Syscalls.h" - --#include -+#include - #include - #include - #include - #include - -+#ifdef __ANDROID__ -+typedef int mqd_t; -+#endif -+ - ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") - ARG_TO_STR(FEX::HLE::x32::compat_ptr, "%lx") - diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Semaphore.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Semaphore.cpp.patch deleted file mode 100644 index 329c32ca7..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Semaphore.cpp.patch +++ /dev/null @@ -1,43 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Semaphore.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Semaphore.cpp -@@ -19,7 +19,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include -@@ -90,6 +90,7 @@ - uint64_t Result{}; - - switch (static_cast(call)) { -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - case OP_SEMOP: { - Result = ::semop(first, reinterpret_cast(ptr), second); - break; -@@ -280,6 +281,7 @@ - } - break; - } -+#endif - case OP_SHMAT: { - Result = static_cast(FEX::HLE::_SyscallHandler)->GetAllocator()-> - shmat(first, reinterpret_cast(ptr), second, reinterpret_cast(third)); -@@ -377,6 +379,7 @@ - void RegisterSemaphore() { - REGISTER_SYSCALL_IMPL_X32(ipc, _ipc); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X32_PASS_MANUAL(semtimedop_time64, semtimedop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops, const struct timespec *timeout) -> uint64_t { - uint64_t Result = ::semtimedop(semid, sops, nsops, timeout); - SYSCALL_ERRNO(); -@@ -454,6 +457,7 @@ - } - SYSCALL_ERRNO(); - }); -+#endif - - } - } diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Signals.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Signals.cpp.patch deleted file mode 100644 index b35ed3e50..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Signals.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Signals.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Signals.cpp -@@ -13,7 +13,7 @@ - #include - #include - #include --#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Socket.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Socket.cpp.patch deleted file mode 100644 index 1ee7c6bc0..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Socket.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Socket.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Socket.cpp -@@ -11,7 +11,7 @@ - #include - - #include --#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Thread.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Thread.cpp.patch deleted file mode 100644 index a4c70dfae..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Thread.cpp.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Thread.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Thread.cpp -@@ -16,9 +16,9 @@ - #include - #include - --#include --#include --#include -+#include -+#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Time.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Time.cpp.patch deleted file mode 100644 index 05ef5b3e4..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Time.cpp.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Time.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Time.cpp -@@ -10,7 +10,6 @@ - - #include "Tests/LinuxSyscalls/x64/Syscalls.h" - --#include - #include - #include - #include -@@ -165,6 +164,7 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X32(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const timeval32 times[2]) -> uint64_t { - uint64_t Result = 0; - if (times) { -@@ -177,6 +177,7 @@ - } - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_X32(utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const compat_ptr times, int flags) -> uint64_t { - uint64_t Result = 0; diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Timer.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Timer.cpp.patch deleted file mode 100644 index 15903e322..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Timer.cpp.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Timer.cpp -+++ b/Source/Tests/LinuxSyscalls/x32/Timer.cpp -@@ -11,7 +11,6 @@ - - #include "Tests/LinuxSyscalls/x64/Syscalls.h" - --#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x32-Types.h.patch b/packages/fex/Source-Tests-LinuxSyscalls-x32-Types.h.patch deleted file mode 100644 index 3c32ce22b..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x32-Types.h.patch +++ /dev/null @@ -1,55 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x32/Types.h -+++ b/Source/Tests/LinuxSyscalls/x32/Types.h -@@ -12,23 +12,25 @@ - #include - #include - #include --#include -+#include - #include - #include - #include - #include - #include --#include -+#include - #include - #include - #include --#include -+#include -+#define semid_ds semid64_ds - #include - #include - #include - #include - #include - #include -+#include - #include - #include - #include -@@ -387,10 +389,13 @@ - uint32_t st_blksize; - uint32_t st_blocks; /* Number 512-byte blocks allocated. */ - uint32_t st_atime_; -+#undef st_atime_nsec - uint32_t st_atime_nsec; - uint32_t st_mtime_; -+#undef st_mtime_nsec - uint32_t st_mtime_nsec; - uint32_t st_ctime_; -+#undef st_ctime_nsec - uint32_t st_ctime_nsec; - uint32_t __unused4; - uint32_t __unused5; -@@ -1164,9 +1169,6 @@ - static_assert(std::is_trivial::value, "Needs to be trivial"); - static_assert(sizeof(sigval32) == 4, "Incorrect size"); - --constexpr size_t SIGEV_MAX_SIZE = 64; --constexpr size_t SIGEV_PAD_SIZE = (SIGEV_MAX_SIZE - (sizeof(int32_t) * 2 + sizeof(sigval32))) / sizeof(int32_t); -- - struct - FEX_ANNOTATE("fex-match") - sigevent32 { diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x64-FD.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x64-FD.cpp.patch deleted file mode 100644 index 34c57c1be..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x64-FD.cpp.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x64/FD.cpp -+++ b/Source/Tests/LinuxSyscalls/x64/FD.cpp -@@ -56,10 +56,12 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X64_PASS(futimesat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timeval times[2]) -> uint64_t { - uint64_t Result = ::futimesat(dirfd, pathname, times); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_X64_PASS(utimensat, [](FEXCore::Core::CpuStateFrame *Frame, int dirfd, const char *pathname, const struct timespec times[2], int flags) -> uint64_t { - uint64_t Result = ::syscall(SYSCALL_DEF(utimensat), dirfd, pathname, times, flags); -@@ -241,11 +243,13 @@ - SYSCALL_ERRNO(); - }); - -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X64_PASS(sync_file_range, [](FEXCore::Core::CpuStateFrame *Frame, int fd, off64_t offset, off64_t nbytes, unsigned int flags) -> uint64_t { - // Flags don't need remapped - uint64_t Result = ::sync_file_range(fd, offset, nbytes, flags); - SYSCALL_ERRNO(); - }); -+#endif - - REGISTER_SYSCALL_IMPL_X64_PASS(fallocate, [](FEXCore::Core::CpuStateFrame *Frame, int fd, int mode, off_t offset, off_t len) -> uint64_t { - uint64_t Result = ::fallocate(fd, mode, offset, len); diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x64-Msg.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x64-Msg.cpp.patch deleted file mode 100644 index b5604303d..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x64-Msg.cpp.patch +++ /dev/null @@ -1,20 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x64/Msg.cpp -+++ b/Source/Tests/LinuxSyscalls/x64/Msg.cpp -@@ -7,12 +7,16 @@ - #include "Tests/LinuxSyscalls/Syscalls.h" - #include "Tests/LinuxSyscalls/x64/Syscalls.h" - --#include -+#include - #include - #include - #include - #include - -+#ifdef __ANDROID__ -+typedef int mqd_t; -+#endif -+ - namespace FEXCore::Core { - struct CpuStateFrame; - } diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x64-Semaphore.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x64-Semaphore.cpp.patch deleted file mode 100644 index 4df44e1cf..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x64-Semaphore.cpp.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp -+++ b/Source/Tests/LinuxSyscalls/x64/Semaphore.cpp -@@ -12,7 +12,7 @@ - - #include - #include --#include -+#include - - namespace FEXCore::Core { - struct CpuStateFrame; -@@ -22,6 +22,7 @@ - - namespace FEX::HLE::x64 { - void RegisterSemaphore() { -+#if !defined(__ANDROID__) || __ANDROID_API__ >= 26 - REGISTER_SYSCALL_IMPL_X64_PASS(semop, [](FEXCore::Core::CpuStateFrame *Frame, int semid, struct sembuf *sops, size_t nsops) -> uint64_t { - uint64_t Result = ::semop(semid, sops, nsops); - SYSCALL_ERRNO(); -@@ -87,5 +88,6 @@ - } - SYSCALL_ERRNO(); - }); -+#endif - } - } diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x64-Thread.cpp.patch b/packages/fex/Source-Tests-LinuxSyscalls-x64-Thread.cpp.patch deleted file mode 100644 index 0ec696a1f..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x64-Thread.cpp.patch +++ /dev/null @@ -1,13 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x64/Thread.cpp -+++ b/Source/Tests/LinuxSyscalls/x64/Thread.cpp -@@ -14,8 +14,8 @@ - #include - #include - --#include --#include -+#include -+#include - #include - #include - #include diff --git a/packages/fex/Source-Tests-LinuxSyscalls-x64-Types.h.patch b/packages/fex/Source-Tests-LinuxSyscalls-x64-Types.h.patch deleted file mode 100644 index a10a0d0b4..000000000 --- a/packages/fex/Source-Tests-LinuxSyscalls-x64-Types.h.patch +++ /dev/null @@ -1,29 +0,0 @@ ---- a/Source/Tests/LinuxSyscalls/x64/Types.h -+++ b/Source/Tests/LinuxSyscalls/x64/Types.h -@@ -13,7 +13,9 @@ - #include - #include - #include --#include -+#include -+#define semid_ds semid64_ds -+#include - #include - #include - -@@ -128,11 +130,15 @@ - __kernel_long_t st_blocks; /* Number 512-byte blocks allocated. */ - - __kernel_ulong_t st_atime_; -+#undef st_atime_nsec - __kernel_ulong_t st_atime_nsec; - __kernel_ulong_t st_mtime_; -+#undef st_mtime_nsec - __kernel_ulong_t st_mtime_nsec; - __kernel_ulong_t st_ctime_; -+#undef st_ctime_nsec - __kernel_ulong_t st_ctime_nsec; -+#undef __unused - __kernel_long_t __unused[3]; - - guest_stat() = delete; diff --git a/packages/fex/Source-Tools-FEXMountDaemon-Main.cpp.patch b/packages/fex/Source-Tools-FEXMountDaemon-Main.cpp.patch deleted file mode 100644 index 79e9f9734..000000000 --- a/packages/fex/Source-Tools-FEXMountDaemon-Main.cpp.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/Source/Tools/FEXMountDaemon/Main.cpp -+++ b/Source/Tools/FEXMountDaemon/Main.cpp -@@ -2,7 +2,7 @@ - #include - - #include --#include -+#include - #include - #include - #include diff --git a/packages/fex/build.sh b/packages/fex/build.sh index f15ff3ddf..6113d3d19 100644 --- a/packages/fex/build.sh +++ b/packages/fex/build.sh @@ -2,15 +2,18 @@ TERMUX_PKG_HOMEPAGE=https://wiki.fex-emu.org/index.php/Main_Page TERMUX_PKG_DESCRIPTION="Fast x86 emulation frontend" TERMUX_PKG_LICENSE="MIT" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=2201 +TERMUX_PKG_VERSION=2203 TERMUX_PKG_SRCURL=https://github.com/FEX-Emu/FEX.git TERMUX_PKG_GIT_BRANCH=FEX-${TERMUX_PKG_VERSION} TERMUX_PKG_DEPENDS="libandroid-shmem, libc++" TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +-DCMAKE_BUILD_TYPE=Release +-DENABLE_STATIC_PIE=False -DBUILD_TESTS=OFF -DENABLE_LTO=OFF -DENABLE_JEMALLOC=OFF -DENABLE_OFFLINE_TELEMETRY=OFF +-DENABLE_TERMUX_BUILD=True " TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686, x86_64" diff --git a/packages/fex/page_size_define.patch b/packages/fex/page_size_define.patch new file mode 100644 index 000000000..bf6957f6b --- /dev/null +++ b/packages/fex/page_size_define.patch @@ -0,0 +1,654 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 58850f43..602acd62 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -21,6 +21,7 @@ option(ENABLE_COMPILE_TIME_TRACE "Enables time trace compile option" FALSE) + option(ENABLE_LIBCXX "Enables LLVM libc++" FALSE) + option(ENABLE_INTERPRETER "Enables FEX's Interpreter" FALSE) + option(ENABLE_CCACHE "Enables ccache for compile caching" TRUE) ++option(ENABLE_TERMUX_BUILD "Forces building for Termux on a non-Termux build machine" FALSE) + + set (X86_C_COMPILER "x86_64-linux-gnu-gcc" CACHE STRING "c compiler for compiling x86 guest libs") + set (X86_CXX_COMPILER "x86_64-linux-gnu-g++" CACHE STRING "c++ compiler for compiling x86 guest libs") +@@ -115,59 +116,7 @@ if (NOT ENABLE_OFFLINE_TELEMETRY) + add_definitions(-DFEX_DISABLE_TELEMETRY=1) + endif() + +-# Check if the build target page size is 4096 +-include(CheckCSourceRuns) +- +-check_c_source_runs( +- "#include +- int main(int argc, char* argv[]) +- { +- return getpagesize() == 4096 ? 0 : 1; +- }" +- PAGEFILE_RESULT +- ) +- +-if (NOT ${PAGEFILE_RESULT}) +- message(FATAL_ERROR "Host PAGE_SIZE is not 4096. Can't build on this target") +-endif() +- +-include(CheckCXXSourceCompiles) +-check_cxx_source_compiles( +-"#include +- int main() { +- return PAGE_SIZE; +- } +- " +- HAS_PAGESIZE) +- +-check_cxx_source_compiles( +-"#include +- int main() { +- return PAGE_SHIFT; +- } +- " +- HAS_PAGESHIFT) +- +-check_cxx_source_compiles( +-"#include +- int main() { +- return PAGE_MASK; +- } +- " +- HAS_PAGEMASK) +- +-if (NOT HAS_PAGESIZE) +- add_definitions(-DPAGE_SIZE=4096) +-endif() +- +-if (NOT HAS_PAGESHIFT) +- add_definitions(-DPAGE_SHIFT=12) +-endif() +-if (NOT HAS_PAGEMASK) +- add_definitions("-DPAGE_MASK=(~(PAGE_SIZE-1))") +-endif() +- +-if(DEFINED ENV{TERMUX_VERSION}) ++if(DEFINED ENV{TERMUX_VERSION} OR ENABLE_TERMUX_BUILD) + add_definitions(-DTERMUX_BUILD=1) + set(TERMUX_BUILD 1) + # Termux doesn't support Jemalloc due to bad interactions between emutls, jemalloc, and scudo +diff --git a/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp b/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp +index 561f9915..2062d4e6 100644 +--- a/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp ++++ b/External/FEXCore/Source/Interface/IR/Passes/RegisterAllocationPass.cpp +@@ -15,6 +15,7 @@ $end_info$ + #include + #include + #include ++#include + + #include + #include +@@ -62,7 +63,7 @@ namespace { + }; + + static_assert(sizeof(RegisterNode) == 128 * 4); +- constexpr size_t REGISTER_NODES_PER_PAGE = PAGE_SIZE / sizeof(RegisterNode); ++ constexpr size_t REGISTER_NODES_PER_PAGE = FHU::FEX_PAGE_SIZE / sizeof(RegisterNode); + + struct RegisterSet { + std::vector Classes; +diff --git a/External/FEXCore/Source/Utils/Allocator.cpp b/External/FEXCore/Source/Utils/Allocator.cpp +index 72b0f5a8..a2605eb8 100644 +--- a/External/FEXCore/Source/Utils/Allocator.cpp ++++ b/External/FEXCore/Source/Utils/Allocator.cpp +@@ -3,6 +3,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -110,10 +111,10 @@ namespace FEXCore::Allocator { + for (int i = 0; i < 64; ++i) { + // Try grabbing a some of the top pages of the range + // x86 allocates some high pages in the top end +- void *Ptr = ::mmap(reinterpret_cast(Size - PAGE_SIZE * i), PAGE_SIZE, PROT_NONE, MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); ++ void *Ptr = ::mmap(reinterpret_cast(Size - FHU::FEX_PAGE_SIZE * i), FHU::FEX_PAGE_SIZE, PROT_NONE, MAP_FIXED_NOREPLACE | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + if (Ptr != (void*)~0ULL) { +- ::munmap(Ptr, PAGE_SIZE); +- if (Ptr == (void*)(Size - PAGE_SIZE * i)) { ++ ::munmap(Ptr, FHU::FEX_PAGE_SIZE); ++ if (Ptr == (void*)(Size - FHU::FEX_PAGE_SIZE * i)) { + return true; + } + } +diff --git a/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp b/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp +index 3dd72671..cc29fd00 100644 +--- a/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp ++++ b/External/FEXCore/Source/Utils/Allocator/64BitAllocator.cpp +@@ -6,6 +6,7 @@ + #include + #include + #include ++#include + + #include + #include +@@ -43,8 +44,8 @@ namespace Alloc::OSAllocator { + // Lower bound is the starting of the range just past the lower 32bits + constexpr static uintptr_t LOWER_BOUND = 0x1'0000'0000ULL; + +- uintptr_t UPPER_BOUND_PAGE = UPPER_BOUND / PAGE_SIZE; +- constexpr static uintptr_t LOWER_BOUND_PAGE = LOWER_BOUND / PAGE_SIZE; ++ uintptr_t UPPER_BOUND_PAGE = UPPER_BOUND / FHU::FEX_PAGE_SIZE; ++ constexpr static uintptr_t LOWER_BOUND_PAGE = LOWER_BOUND / FHU::FEX_PAGE_SIZE; + + struct ReservedVMARegion { + uintptr_t Base; +@@ -81,19 +82,19 @@ namespace Alloc::OSAllocator { + // 0x100'0000 Pages + // 1 bit per page for tracking means 0x20'0000 (Pages / 8) bytes of flex space + // Which is 2MB of tracking +- uint64_t NumElements = (Size >> PAGE_SHIFT) * sizeof(uint64_t); ++ uint64_t NumElements = (Size >> FHU::FEX_PAGE_SHIFT) * sizeof(uint64_t); + return sizeof(LiveVMARegion) + FEXCore::FlexBitSet::Size(NumElements); + } + + static void InitializeVMARegionUsed(LiveVMARegion *Region, size_t AdditionalSize) { +- size_t SizeOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(Region->SlabInfo->RegionSize), PAGE_SIZE); ++ size_t SizeOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(Region->SlabInfo->RegionSize), FHU::FEX_PAGE_SIZE); + size_t SizePlusManagedData = SizeOfLiveRegion + AdditionalSize; + + Region->FreeSpace = Region->SlabInfo->RegionSize - SizePlusManagedData; + +- size_t NumPages = SizePlusManagedData >> PAGE_SHIFT; ++ size_t NumPages = SizePlusManagedData >> FHU::FEX_PAGE_SHIFT; + // Memset the full tracking to zero to state nothing used +- Region->UsedPages.MemSet(Region->SlabInfo->RegionSize >> PAGE_SHIFT); ++ Region->UsedPages.MemSet(Region->SlabInfo->RegionSize >> FHU::FEX_PAGE_SHIFT); + // Set our reserved pages + for (size_t i = 0; i < NumPages; ++i) { + // Set our used pages +@@ -119,7 +120,7 @@ namespace Alloc::OSAllocator { + + ReservedRegions->erase(ReservedIterator); + // mprotect the new region we've allocated +- size_t SizeOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(ReservedRegion->RegionSize), PAGE_SIZE); ++ size_t SizeOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(ReservedRegion->RegionSize), FHU::FEX_PAGE_SIZE); + size_t SizePlusManagedData = UsedSize + SizeOfLiveRegion; + + [[maybe_unused]] auto Res = mprotect(reinterpret_cast(ReservedRegion->Base), SizePlusManagedData, PROT_READ | PROT_WRITE); +@@ -147,7 +148,7 @@ void OSAllocator_64Bit::DetermineVASize() { + size_t Bits = FEXCore::Allocator::DetermineVASize(); + uintptr_t Size = 1ULL << Bits; + UPPER_BOUND = Size; +- UPPER_BOUND_PAGE = UPPER_BOUND / PAGE_SIZE; ++ UPPER_BOUND_PAGE = UPPER_BOUND / FHU::FEX_PAGE_SIZE; + } + + void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { +@@ -160,13 +161,13 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + + uint64_t Addr = reinterpret_cast(addr); + // Addr must be page aligned +- if (Addr & ~PAGE_MASK) { ++ if (Addr & ~FHU::FEX_PAGE_MASK) { + return reinterpret_cast(-EINVAL); + } + + // If FD is provided then offset must also be page aligned + if (fd != -1 && +- offset & ~PAGE_MASK) { ++ offset & ~FHU::FEX_PAGE_MASK) { + return reinterpret_cast(-EINVAL); + } + +@@ -176,10 +177,10 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + } + + bool Fixed = (flags & MAP_FIXED) || (flags & MAP_FIXED_NOREPLACE); +- length = FEXCore::AlignUp(length, PAGE_SIZE); ++ length = FEXCore::AlignUp(length, FHU::FEX_PAGE_SIZE); + + uint64_t AddrEnd = Addr + length; +- size_t NumberOfPages = length / PAGE_SIZE; ++ size_t NumberOfPages = length / FHU::FEX_PAGE_SIZE; + + // This needs a mutex to be thread safe + FHU::ScopedSignalMaskWithMutex lk(AllocationMutex); +@@ -223,14 +224,14 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + + auto CheckIfRangeFits = [&AllocatedOffset](LiveVMARegion *Region, uint64_t length, int prot, int flags, int fd, off_t offset, uint64_t StartingPosition = 0) -> std::pair { + uint64_t AllocatedPage{}; +- uint64_t NumberOfPages = length >> PAGE_SHIFT; ++ uint64_t NumberOfPages = length >> FHU::FEX_PAGE_SHIFT; + + if (Region->FreeSpace >= length) { + uint64_t LastAllocation = + StartingPosition ? +- (StartingPosition - Region->SlabInfo->Base) >> PAGE_SHIFT ++ (StartingPosition - Region->SlabInfo->Base) >> FHU::FEX_PAGE_SHIFT + : Region->LastPageAllocation; +- size_t RegionNumberOfPages = Region->SlabInfo->RegionSize >> PAGE_SHIFT; ++ size_t RegionNumberOfPages = Region->SlabInfo->RegionSize >> FHU::FEX_PAGE_SHIFT; + + // Backward scan + // We need to do a backward scan first to fill any holes +@@ -298,7 +299,7 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + } + + if (AllocatedPage) { +- AllocatedOffset = Region->SlabInfo->Base + AllocatedPage * PAGE_SIZE; ++ AllocatedOffset = Region->SlabInfo->Base + AllocatedPage * FHU::FEX_PAGE_SIZE; + + // We need to setup protections for this + void *MMapResult = ::mmap(reinterpret_cast(AllocatedOffset), +@@ -388,7 +389,7 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + if (!LiveRegion) { + // Couldn't find a fit in the live regions + // Allocate a new reserved region +- size_t lengthOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(length), PAGE_SIZE); ++ size_t lengthOfLiveRegion = FEXCore::AlignUp(LiveVMARegion::GetSizeWithFlexSet(length), FHU::FEX_PAGE_SIZE); + size_t lengthPlusManagedData = length + lengthOfLiveRegion; + for (auto it = ReservedRegions->begin(); it != ReservedRegions->end(); ++it) { + if ((*it)->RegionSize >= lengthPlusManagedData) { +@@ -402,7 +403,7 @@ void *OSAllocator_64Bit::Mmap(void *addr, size_t length, int prot, int flags, in + if (LiveRegion) { + // Mark the pages as used + uintptr_t RegionBegin = LiveRegion->SlabInfo->Base; +- uintptr_t MappedBegin = (AllocatedOffset - RegionBegin) >> PAGE_SHIFT; ++ uintptr_t MappedBegin = (AllocatedOffset - RegionBegin) >> FHU::FEX_PAGE_SHIFT; + + for (size_t i = 0; i < NumberOfPages; ++i) { + LiveRegion->UsedPages.Set(MappedBegin + i); +@@ -428,11 +429,11 @@ int OSAllocator_64Bit::Munmap(void *addr, size_t length) { + + uint64_t Addr = reinterpret_cast(addr); + +- if (Addr & ~PAGE_MASK) { ++ if (Addr & ~FHU::FEX_PAGE_MASK) { + return -EINVAL; + } + +- if (length & ~PAGE_MASK) { ++ if (length & ~FHU::FEX_PAGE_MASK) { + return -EINVAL; + } + +@@ -443,7 +444,7 @@ int OSAllocator_64Bit::Munmap(void *addr, size_t length) { + // This needs a mutex to be thread safe + FHU::ScopedSignalMaskWithMutex lk(AllocationMutex); + +- length = FEXCore::AlignUp(length, PAGE_SIZE); ++ length = FEXCore::AlignUp(length, FHU::FEX_PAGE_SIZE); + + uintptr_t PtrBegin = reinterpret_cast(addr); + uintptr_t PtrEnd = PtrBegin + length; +@@ -457,8 +458,8 @@ int OSAllocator_64Bit::Munmap(void *addr, size_t length) { + // Live region fully encompasses slab range + + uint64_t FreedPages{}; +- uint32_t SlabPageBegin = (PtrBegin - RegionBegin) >> PAGE_SHIFT; +- uint64_t PagesToFree = length >> PAGE_SHIFT; ++ uint32_t SlabPageBegin = (PtrBegin - RegionBegin) >> FHU::FEX_PAGE_SHIFT; ++ uint64_t PagesToFree = length >> FHU::FEX_PAGE_SHIFT; + + for (size_t i = 0; i < PagesToFree; ++i) { + FreedPages += (*it)->UsedPages.TestAndClear(SlabPageBegin + i) ? 1 : 0; +diff --git a/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h b/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h +index b69b1023..84bd2b59 100644 +--- a/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h ++++ b/External/FEXCore/Source/Utils/Allocator/IntrusiveArenaAllocator.h +@@ -4,6 +4,7 @@ + #include "HostAllocator.h" + + #include ++#include + + #include + #include +@@ -87,9 +88,9 @@ namespace Alloc { + IntrusiveArenaAllocator(void* Ptr, size_t _Size) + : Begin {reinterpret_cast(Ptr)} + , Size {_Size} { +- uint64_t NumberOfPages = _Size / PAGE_SIZE; ++ uint64_t NumberOfPages = _Size / FHU::FEX_PAGE_SIZE; + uint64_t UsedBits = FEXCore::AlignUp(sizeof(IntrusiveArenaAllocator) + +- Size / PAGE_SIZE / 8, PAGE_SIZE); ++ Size / FHU::FEX_PAGE_SIZE / 8, FHU::FEX_PAGE_SIZE); + for (size_t i = 0; i < UsedBits; ++i) { + UsedPages.Set(i); + } +@@ -117,7 +118,7 @@ namespace Alloc { + void *do_allocate(std::size_t bytes, std::size_t alignment) override { + std::scoped_lock lk{AllocationMutex}; + +- size_t NumberPages = FEXCore::AlignUp(bytes, PAGE_SIZE) / PAGE_SIZE; ++ size_t NumberPages = FEXCore::AlignUp(bytes, FHU::FEX_PAGE_SIZE) / FHU::FEX_PAGE_SIZE; + + uintptr_t AllocatedOffset{}; + +@@ -161,7 +162,7 @@ namespace Alloc { + LastAllocatedPageOffset = AllocatedOffset + NumberPages; + + // Now convert this base page to a pointer and return it +- return reinterpret_cast(Begin + AllocatedOffset * PAGE_SIZE); ++ return reinterpret_cast(Begin + AllocatedOffset * FHU::FEX_PAGE_SIZE); + } + + return nullptr; +@@ -170,8 +171,8 @@ namespace Alloc { + void do_deallocate(void* p, std::size_t bytes, std::size_t alignment) override { + std::scoped_lock lk{AllocationMutex}; + +- uintptr_t PageOffset = (reinterpret_cast(p) - Begin) / PAGE_SIZE; +- size_t NumPages = FEXCore::AlignUp(bytes, PAGE_SIZE) / PAGE_SIZE; ++ uintptr_t PageOffset = (reinterpret_cast(p) - Begin) / FHU::FEX_PAGE_SIZE; ++ size_t NumPages = FEXCore::AlignUp(bytes, FHU::FEX_PAGE_SIZE) / FHU::FEX_PAGE_SIZE; + + // Walk the allocation list and deallocate + uint64_t FreedPages{}; +diff --git a/FEXHeaderUtils/FEXHeaderUtils/TypeDefines.h b/FEXHeaderUtils/FEXHeaderUtils/TypeDefines.h +new file mode 100644 +index 00000000..8d75d4b0 +--- /dev/null ++++ b/FEXHeaderUtils/FEXHeaderUtils/TypeDefines.h +@@ -0,0 +1,11 @@ ++#pragma once ++#include ++ ++namespace FHU { ++ // FEX assumes an operating page size of 4096 ++ // To work around build systems that build on a 16k/64k page size, define our page size here ++ // Don't use the system provided PAGE_SIZE define because of this. ++ constexpr size_t FEX_PAGE_SIZE = 4096; ++ constexpr size_t FEX_PAGE_SHIFT = 12; ++ constexpr size_t FEX_PAGE_MASK = ~(FEX_PAGE_SIZE - 1); ++} +diff --git a/Source/Tests/HarnessHelpers.h b/Source/Tests/HarnessHelpers.h +index d15bf2dd..60f95c1d 100644 +--- a/Source/Tests/HarnessHelpers.h ++++ b/Source/Tests/HarnessHelpers.h +@@ -22,6 +22,7 @@ + #include + #include + #include ++#include + + #include + +@@ -396,14 +397,14 @@ namespace FEX::HarnessHelper { + }; + + if (LimitedSize) { +- DoMMap(0xe000'0000, PAGE_SIZE * 10); ++ DoMMap(0xe000'0000, FHU::FEX_PAGE_SIZE * 10); + + // SIB8 + // We test [-128, -126] (Bottom) + // We test [-8, 8] (Middle) + // We test [120, 127] (Top) + // Can fit in two pages +- DoMMap(0xe800'0000 - PAGE_SIZE, PAGE_SIZE * 2); ++ DoMMap(0xe800'0000 - FHU::FEX_PAGE_SIZE, FHU::FEX_PAGE_SIZE * 2); + } + else { + // This is scratch memory location and SIB8 location +@@ -413,7 +414,7 @@ namespace FEX::HarnessHelper { + } + + // Map in the memory region for the test file +- size_t Length = FEXCore::AlignUp(RawFile.size(), PAGE_SIZE); ++ size_t Length = FEXCore::AlignUp(RawFile.size(), FHU::FEX_PAGE_SIZE); + Code_start_page = reinterpret_cast(DoMMap(Code_start_page, Length)); + mprotect(reinterpret_cast(Code_start_page), Length, PROT_READ | PROT_WRITE | PROT_EXEC); + RIP = Code_start_page; +@@ -446,7 +447,7 @@ namespace FEX::HarnessHelper { + bool Is64BitMode() const { return Config.Is64BitMode(); } + + private: +- constexpr static uint64_t STACK_SIZE = PAGE_SIZE; ++ constexpr static uint64_t STACK_SIZE = FHU::FEX_PAGE_SIZE; + constexpr static uint64_t STACK_OFFSET = 0xc000'0000; + // Zero is special case to know when we are done + uint64_t Code_start_page = 0x1'0000; +diff --git a/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp b/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp +index 03b6d17f..422b7e95 100644 +--- a/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp ++++ b/Source/Tests/LinuxSyscalls/LinuxAllocator.cpp +@@ -3,6 +3,7 @@ + + #include + #include ++#include + + #include + #include +@@ -20,8 +21,8 @@ namespace FEX::HLE { + class MemAllocator32Bit final : public FEX::HLE::MemAllocator { + private: + static constexpr uint64_t BASE_KEY = 16; +- const uint64_t TOP_KEY = 0xFFFF'F000ULL >> PAGE_SHIFT; +- const uint64_t TOP_KEY32BIT = 0x1F'F000ULL >> PAGE_SHIFT; ++ const uint64_t TOP_KEY = 0xFFFF'F000ULL >> FHU::FEX_PAGE_SHIFT; ++ const uint64_t TOP_KEY32BIT = 0x1F'F000ULL >> FHU::FEX_PAGE_SHIFT; + + public: + MemAllocator32Bit() { +@@ -132,10 +133,10 @@ uint64_t MemAllocator32Bit::FindPageRange_TopDown(uint64_t Start, size_t Pages) + + void *MemAllocator32Bit::mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset) { + std::scoped_lock lk{AllocMutex}; +- size_t PagesLength = FEXCore::AlignUp(length, PAGE_SIZE) >> PAGE_SHIFT; ++ size_t PagesLength = FEXCore::AlignUp(length, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + + uintptr_t Addr = reinterpret_cast(addr); +- uintptr_t PageAddr = Addr >> PAGE_SHIFT; ++ uintptr_t PageAddr = Addr >> FHU::FEX_PAGE_SHIFT; + + // Define MAP_FIXED_NOREPLACE ourselves to ensure we always parse this flag + constexpr int FEX_MAP_FIXED_NOREPLACE = 0x100000; +@@ -143,13 +144,13 @@ void *MemAllocator32Bit::mmap(void *addr, size_t length, int prot, int flags, in + (flags & FEX_MAP_FIXED_NOREPLACE)); + + // Both Addr and length must be page aligned +- if (Addr & ~PAGE_MASK) { ++ if (Addr & ~FHU::FEX_PAGE_MASK) { + return reinterpret_cast(-EINVAL); + } + + // If we do have an fd then offset must be page aligned + if (fd != -1 && +- offset & ~PAGE_MASK) { ++ offset & ~FHU::FEX_PAGE_MASK) { + return reinterpret_cast(-EINVAL); + } + +@@ -190,7 +191,7 @@ restart: + { + // Try and map the range + void *MappedPtr = ::mmap( +- reinterpret_cast(LowerPage<< PAGE_SHIFT), ++ reinterpret_cast(LowerPage<< FHU::FEX_PAGE_SHIFT), + length, + prot, + flags | FEX_MAP_FIXED_NOREPLACE, +@@ -202,10 +203,10 @@ restart: + return reinterpret_cast(-errno); + } + else if (MappedPtr == MAP_FAILED || +- MappedPtr >= reinterpret_cast(TOP_KEY << PAGE_SHIFT)) { ++ MappedPtr >= reinterpret_cast(TOP_KEY << FHU::FEX_PAGE_SHIFT)) { + // Handles the case where MAP_FIXED_NOREPLACE failed with MAP_FAILED + // or if the host system's kernel isn't new enough then it returns the wrong pointer +- if (MappedPtr >= reinterpret_cast(TOP_KEY << PAGE_SHIFT)) { ++ if (MappedPtr >= reinterpret_cast(TOP_KEY << FHU::FEX_PAGE_SHIFT)) { + // Make sure to munmap this so we don't leak memory + ::munmap(MappedPtr, length); + } +@@ -251,14 +252,14 @@ restart: + } + else { + void *MappedPtr = ::mmap( +- reinterpret_cast(PageAddr << PAGE_SHIFT), +- PagesLength << PAGE_SHIFT, ++ reinterpret_cast(PageAddr << FHU::FEX_PAGE_SHIFT), ++ PagesLength << FHU::FEX_PAGE_SHIFT, + prot, + flags, + fd, + offset); + +- if (MappedPtr >= reinterpret_cast(TOP_KEY << PAGE_SHIFT) && ++ if (MappedPtr >= reinterpret_cast(TOP_KEY << FHU::FEX_PAGE_SHIFT) && + (flags & FEX_MAP_FIXED_NOREPLACE)) { + // Handles the case where MAP_FIXED_NOREPLACE isn't handled by the host system's + // kernel and returns the wrong pointer +@@ -279,19 +280,19 @@ restart: + + int MemAllocator32Bit::munmap(void *addr, size_t length) { + std::scoped_lock lk{AllocMutex}; +- size_t PagesLength = FEXCore::AlignUp(length, PAGE_SIZE) >> PAGE_SHIFT; ++ size_t PagesLength = FEXCore::AlignUp(length, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + + uintptr_t Addr = reinterpret_cast(addr); +- uintptr_t PageAddr = Addr >> PAGE_SHIFT; ++ uintptr_t PageAddr = Addr >> FHU::FEX_PAGE_SHIFT; + + uintptr_t PageEnd = PageAddr + PagesLength; + + // Both Addr and length must be page aligned +- if (Addr & ~PAGE_MASK) { ++ if (Addr & ~FHU::FEX_PAGE_MASK) { + return -EINVAL; + } + +- if (length & ~PAGE_MASK) { ++ if (length & ~FHU::FEX_PAGE_MASK) { + return -EINVAL; + } + +@@ -307,7 +308,7 @@ int MemAllocator32Bit::munmap(void *addr, size_t length) { + + while (PageAddr != PageEnd) { + // Always pass to munmap, it may be something allocated we aren't tracking +- int Result = ::munmap(reinterpret_cast(PageAddr << PAGE_SHIFT), PAGE_SIZE); ++ int Result = ::munmap(reinterpret_cast(PageAddr << FHU::FEX_PAGE_SHIFT), FHU::FEX_PAGE_SIZE); + if (Result != 0) { + return -errno; + } +@@ -323,8 +324,8 @@ int MemAllocator32Bit::munmap(void *addr, size_t length) { + } + + void *MemAllocator32Bit::mremap(void *old_address, size_t old_size, size_t new_size, int flags, void *new_address) { +- size_t OldPagesLength = FEXCore::AlignUp(old_size, PAGE_SIZE) >> PAGE_SHIFT; +- size_t NewPagesLength = FEXCore::AlignUp(new_size, PAGE_SIZE) >> PAGE_SHIFT; ++ size_t OldPagesLength = FEXCore::AlignUp(old_size, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; ++ size_t NewPagesLength = FEXCore::AlignUp(new_size, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + + { + std::scoped_lock lk{AllocMutex}; +@@ -335,12 +336,12 @@ void *MemAllocator32Bit::mremap(void *old_address, size_t old_size, size_t new_s + if (!(flags & MREMAP_DONTUNMAP)) { + // Unmap the old location + uintptr_t OldAddr = reinterpret_cast(old_address); +- SetFreePages(OldAddr >> PAGE_SHIFT, OldPagesLength); ++ SetFreePages(OldAddr >> FHU::FEX_PAGE_SHIFT, OldPagesLength); + } + + // Map the new pages + uintptr_t NewAddr = reinterpret_cast(MappedPtr); +- SetUsedPages(NewAddr >> PAGE_SHIFT, NewPagesLength); ++ SetUsedPages(NewAddr >> FHU::FEX_PAGE_SHIFT, NewPagesLength); + } + else { + return reinterpret_cast(-errno); +@@ -348,15 +349,15 @@ void *MemAllocator32Bit::mremap(void *old_address, size_t old_size, size_t new_s + } + else { + uintptr_t OldAddr = reinterpret_cast(old_address); +- uintptr_t OldPageAddr = OldAddr >> PAGE_SHIFT; ++ uintptr_t OldPageAddr = OldAddr >> FHU::FEX_PAGE_SHIFT; + + if (NewPagesLength < OldPagesLength) { + void *MappedPtr = ::mremap(old_address, old_size, new_size, flags & ~MREMAP_MAYMOVE); + + if (MappedPtr != MAP_FAILED) { + // Clear the pages that we just shrunk +- size_t NewPagesLength = FEXCore::AlignUp(new_size, PAGE_SIZE) >> PAGE_SHIFT; +- uintptr_t NewPageAddr = reinterpret_cast(MappedPtr) >> PAGE_SHIFT; ++ size_t NewPagesLength = FEXCore::AlignUp(new_size, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; ++ uintptr_t NewPageAddr = reinterpret_cast(MappedPtr) >> FHU::FEX_PAGE_SHIFT; + SetFreePages(NewPageAddr + NewPagesLength, OldPagesLength - NewPagesLength); + return MappedPtr; + } +@@ -380,9 +381,9 @@ void *MemAllocator32Bit::mremap(void *old_address, size_t old_size, size_t new_s + + if (MappedPtr != MAP_FAILED) { + // Map the new pages +- size_t NewPagesLength = FEXCore::AlignUp(new_size, PAGE_SIZE) >> PAGE_SHIFT; ++ size_t NewPagesLength = FEXCore::AlignUp(new_size, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + uintptr_t NewAddr = reinterpret_cast(MappedPtr); +- SetUsedPages(NewAddr >> PAGE_SHIFT, NewPagesLength); ++ SetUsedPages(NewAddr >> FHU::FEX_PAGE_SHIFT, NewPagesLength); + return MappedPtr; + } + else if (!(flags & MREMAP_MAYMOVE)) { +@@ -416,13 +417,13 @@ void *MemAllocator32Bit::mremap(void *old_address, size_t old_size, size_t new_s + // If we have both MREMAP_DONTUNMAP not set and the new pointer is at a new location + // Make sure to clear the old mapping + uintptr_t OldAddr = reinterpret_cast(old_address); +- SetFreePages(OldAddr >> PAGE_SHIFT , OldPagesLength); ++ SetFreePages(OldAddr >> FHU::FEX_PAGE_SHIFT , OldPagesLength); + } + + // Map the new pages +- size_t NewPagesLength = FEXCore::AlignUp(new_size, PAGE_SIZE) >> PAGE_SHIFT; ++ size_t NewPagesLength = FEXCore::AlignUp(new_size, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + uintptr_t NewAddr = reinterpret_cast(MappedPtr); +- SetUsedPages(NewAddr >> PAGE_SHIFT, NewPagesLength); ++ SetUsedPages(NewAddr >> FHU::FEX_PAGE_SHIFT, NewPagesLength); + return MappedPtr; + } + +@@ -445,7 +446,7 @@ uint64_t MemAllocator32Bit::shmat(int shmid, const void* shmaddr, int shmflg, ui + } + + uintptr_t NewAddr = reinterpret_cast(Result); +- uintptr_t NewPageAddr = NewAddr >> PAGE_SHIFT; ++ uintptr_t NewPageAddr = NewAddr >> FHU::FEX_PAGE_SHIFT; + + // Add to the map + PageToShm[NewPageAddr] = shmid; +@@ -457,7 +458,7 @@ uint64_t MemAllocator32Bit::shmat(int shmid, const void* shmaddr, int shmflg, ui + + if (shmctl(shmid, IPC_STAT, &buf) == 0) { + // Map the new pages +- size_t NewPagesLength = buf.shm_segsz >> PAGE_SHIFT; ++ size_t NewPagesLength = buf.shm_segsz >> FHU::FEX_PAGE_SHIFT; + SetUsedPages(NewPageAddr, NewPagesLength); + } + +@@ -475,7 +476,7 @@ uint64_t MemAllocator32Bit::shmat(int shmid, const void* shmaddr, int shmflg, ui + uint64_t PagesLength{}; + + if (shmctl(shmid, IPC_STAT, &buf) == 0) { +- PagesLength = FEXCore::AlignUp(buf.shm_segsz, PAGE_SIZE) >> PAGE_SHIFT; ++ PagesLength = FEXCore::AlignUp(buf.shm_segsz, FHU::FEX_PAGE_SIZE) >> FHU::FEX_PAGE_SHIFT; + } + else { + return -EINVAL; +@@ -501,7 +502,7 @@ restart: + // Try and map the range + void *MappedPtr = ::shmat( + shmid, +- reinterpret_cast(LowerPage << PAGE_SHIFT), ++ reinterpret_cast(LowerPage << FHU::FEX_PAGE_SHIFT), + shmflg); + + if (MappedPtr == MAP_FAILED) { +@@ -544,7 +545,7 @@ restart: + } + } + uint64_t MemAllocator32Bit::shmdt(const void* shmaddr) { +- uint32_t AddrPage = reinterpret_cast(shmaddr) >> PAGE_SHIFT; ++ uint32_t AddrPage = reinterpret_cast(shmaddr) >> FHU::FEX_PAGE_SHIFT; + auto it = PageToShm.find(AddrPage); + + if (it == PageToShm.end()) {