summaryrefslogtreecommitdiff
path: root/src/lj_alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lj_alloc.c')
-rw-r--r--src/lj_alloc.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lj_alloc.c b/src/lj_alloc.c
index 2c686597..2f3fb473 100644
--- a/src/lj_alloc.c
+++ b/src/lj_alloc.c
@@ -72,7 +72,7 @@
72 72
73#define IS_DIRECT_BIT (SIZE_T_ONE) 73#define IS_DIRECT_BIT (SIZE_T_ONE)
74 74
75#ifdef LUA_USE_WIN 75#if LJ_TARGET_WINDOWS
76 76
77#define WIN32_LEAN_AND_MEAN 77#define WIN32_LEAN_AND_MEAN
78#include <windows.h> 78#include <windows.h>
@@ -166,13 +166,12 @@ static LJ_AINLINE int CALL_MUNMAP(void *ptr, size_t size)
166#if LJ_64 166#if LJ_64
167/* 64 bit mode needs special support for allocating memory in the lower 2GB. */ 167/* 64 bit mode needs special support for allocating memory in the lower 2GB. */
168 168
169#if defined(__linux__) 169#if LJ_TARGET_LINUX
170 170
171/* Actually this only gives us max. 1GB in current Linux kernels. */ 171/* Actually this only gives us max. 1GB in current Linux kernels. */
172#define CALL_MMAP(s) mmap(NULL, (s), MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0) 172#define CALL_MMAP(s) mmap(NULL, (s), MMAP_PROT, MAP_32BIT|MMAP_FLAGS, -1, 0)
173 173
174#elif (defined(__MACH__) && defined(__APPLE__)) || \ 174#elif LJ_TARGET_OSX || defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
175 defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
176 175
177/* OSX and FreeBSD mmap() use a naive first-fit linear search. 176/* OSX and FreeBSD mmap() use a naive first-fit linear search.
178** That's perfect for us. Except that -pagezero_size must be set for OSX, 177** That's perfect for us. Except that -pagezero_size must be set for OSX,
@@ -233,7 +232,7 @@ static LJ_AINLINE void *CALL_MMAP(size_t size)
233#define DIRECT_MMAP(s) CALL_MMAP(s) 232#define DIRECT_MMAP(s) CALL_MMAP(s)
234#define CALL_MUNMAP(a, s) munmap((a), (s)) 233#define CALL_MUNMAP(a, s) munmap((a), (s))
235 234
236#ifdef __linux__ 235#if LJ_TARGET_LINUX
237/* Need to define _GNU_SOURCE to get the mremap prototype. */ 236/* Need to define _GNU_SOURCE to get the mremap prototype. */
238#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) 237#define CALL_MREMAP(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv))
239#define CALL_MREMAP_NOMOVE 0 238#define CALL_MREMAP_NOMOVE 0
@@ -420,7 +419,7 @@ typedef struct malloc_state *mstate;
420 (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\ 419 (((S) + (DEFAULT_GRANULARITY - SIZE_T_ONE))\
421 & ~(DEFAULT_GRANULARITY - SIZE_T_ONE)) 420 & ~(DEFAULT_GRANULARITY - SIZE_T_ONE))
422 421
423#ifdef LUA_USE_WIN 422#if LJ_TARGET_WINDOWS
424#define mmap_align(S) granularity_align(S) 423#define mmap_align(S) granularity_align(S)
425#else 424#else
426#define mmap_align(S) page_align(S) 425#define mmap_align(S) page_align(S)