diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lj_alloc.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lj_alloc.c b/src/lj_alloc.c index 5d0834ec..95d15d04 100644 --- a/src/lj_alloc.c +++ b/src/lj_alloc.c | |||
| @@ -215,6 +215,12 @@ static int CALL_MUNMAP(void *ptr, size_t size) | |||
| 215 | 215 | ||
| 216 | #if LJ_ALLOC_MMAP_PROBE | 216 | #if LJ_ALLOC_MMAP_PROBE |
| 217 | 217 | ||
| 218 | #ifdef MAP_TRYFIXED | ||
| 219 | #define MMAP_FLAGS_PROBE (MMAP_FLAGS|MAP_TRYFIXED) | ||
| 220 | #else | ||
| 221 | #define MMAP_FLAGS_PROBE MMAP_FLAGS | ||
| 222 | #endif | ||
| 223 | |||
| 218 | #define LJ_ALLOC_MMAP_PROBE_MAX 30 | 224 | #define LJ_ALLOC_MMAP_PROBE_MAX 30 |
| 219 | #define LJ_ALLOC_MMAP_PROBE_LINEAR 5 | 225 | #define LJ_ALLOC_MMAP_PROBE_LINEAR 5 |
| 220 | 226 | ||
| @@ -247,7 +253,7 @@ static void *mmap_probe(size_t size) | |||
| 247 | int olderr = errno; | 253 | int olderr = errno; |
| 248 | int retry; | 254 | int retry; |
| 249 | for (retry = 0; retry < LJ_ALLOC_MMAP_PROBE_MAX; retry++) { | 255 | for (retry = 0; retry < LJ_ALLOC_MMAP_PROBE_MAX; retry++) { |
| 250 | void *p = mmap((void *)hint_addr, size, MMAP_PROT, MMAP_FLAGS, -1, 0); | 256 | void *p = mmap((void *)hint_addr, size, MMAP_PROT, MMAP_FLAGS_PROBE, -1, 0); |
| 251 | uintptr_t addr = (uintptr_t)p; | 257 | uintptr_t addr = (uintptr_t)p; |
| 252 | if ((addr >> LJ_ALLOC_MBITS) == 0 && addr >= LJ_ALLOC_MMAP_PROBE_LOWER) { | 258 | if ((addr >> LJ_ALLOC_MBITS) == 0 && addr >= LJ_ALLOC_MMAP_PROBE_LOWER) { |
| 253 | /* We got a suitable address. Bump the hint address. */ | 259 | /* We got a suitable address. Bump the hint address. */ |
