Skip to content

Commit

Permalink
fix(page): nearby alloc on x86
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 9, 2024
1 parent aeec3f6 commit 50c01a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/page.linux.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "page.hpp"
#include "constants.hpp"

#include <cassert>
#include <cinttypes>
Expand Down Expand Up @@ -208,6 +209,11 @@ namespace lime
std::shared_ptr<page> page::allocate<alloc_policy::nearby>(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;

Expand Down
7 changes: 7 additions & 0 deletions src/page.win.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "page.hpp"
#include "constants.hpp"

#include <limits>
#include <windows.h>
Expand Down Expand Up @@ -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{};

Expand Down

0 comments on commit 50c01a6

Please sign in to comment.