From 50c01a6818a98e1c861894823440295d58c5be60 Mon Sep 17 00:00:00 2001 From: Curve Date: Fri, 10 May 2024 00:19:46 +0200 Subject: [PATCH] fix(page): nearby alloc on x86 --- src/page.linux.cpp | 6 ++++++ src/page.win.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/src/page.linux.cpp b/src/page.linux.cpp index 2815435..27bfdcf 100644 --- a/src/page.linux.cpp +++ b/src/page.linux.cpp @@ -1,4 +1,5 @@ #include "page.hpp" +#include "constants.hpp" #include #include @@ -208,6 +209,11 @@ namespace lime std::shared_ptr page::allocate(std::uintptr_t where, std::size_t size, protection protection) { + if constexpr (lime::arch == lime::architecture::x86) + { + return allocate(size, protection); + } + auto aligned = where & (getpagesize() - 1) ? (where + getpagesize()) & ~(getpagesize() - 1) : where; auto *alloc = MAP_FAILED; diff --git a/src/page.win.cpp b/src/page.win.cpp index ef0c4eb..3621869 100644 --- a/src/page.win.cpp +++ b/src/page.win.cpp @@ -1,4 +1,5 @@ #include "page.hpp" +#include "constants.hpp" #include #include @@ -220,6 +221,12 @@ namespace lime #ifdef LIME_DISABLE_ALLOC2 return nullptr; #else + + if constexpr (lime::arch == lime::architecture::x86) + { + return allocate(size, protection); + } + MEM_EXTENDED_PARAMETER param{}; MEM_ADDRESS_REQUIREMENTS requirements{};