Fix Windows build.
This commit is contained in:
parent
8c691767da
commit
5dcb212fc7
|
@ -27,7 +27,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(MAP_32BIT)
|
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#define PAGE_MASK (getpagesize() - 1)
|
#define PAGE_MASK (getpagesize() - 1)
|
||||||
#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
|
#define round_page(x) ((((unsigned long)(x)) + PAGE_MASK) & ~(PAGE_MASK))
|
||||||
|
@ -38,15 +38,14 @@
|
||||||
|
|
||||||
void* AllocateExecutableMemory(size_t size, bool low)
|
void* AllocateExecutableMemory(size_t size, bool low)
|
||||||
{
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
||||||
|
#else
|
||||||
static char *map_hint = 0;
|
static char *map_hint = 0;
|
||||||
#if defined(__x86_64__) && !defined(MAP_32BIT)
|
#if defined(__x86_64__) && !defined(MAP_32BIT)
|
||||||
if (low && (!map_hint))
|
if (low && (!map_hint))
|
||||||
map_hint = (char*)round_page(512*1024*1024); /* 0.5 GB rounded up to the next page */
|
map_hint = (char*)round_page(512*1024*1024); /* 0.5 GB rounded up to the next page */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32)
|
|
||||||
void* ptr = VirtualAlloc(0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
|
|
||||||
#else
|
|
||||||
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
void* ptr = mmap(map_hint, size, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||||
MAP_ANON | MAP_PRIVATE
|
MAP_ANON | MAP_PRIVATE
|
||||||
#if defined(__x86_64__)
|
#if defined(__x86_64__)
|
||||||
|
@ -72,7 +71,7 @@ void* AllocateExecutableMemory(size_t size, bool low)
|
||||||
#endif
|
#endif
|
||||||
PanicAlert("Failed to allocate executable memory");
|
PanicAlert("Failed to allocate executable memory");
|
||||||
}
|
}
|
||||||
#if defined(__x86_64__) && !defined(MAP_32BIT)
|
#if !defined(_WIN32) && defined(__x86_64__) && !defined(MAP_32BIT)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (low)
|
if (low)
|
||||||
|
|
Loading…
Reference in New Issue