diff options
| author | Mike Pall <mike> | 2016-05-23 14:28:28 +0200 |
|---|---|---|
| committer | Mike Pall <mike> | 2016-05-23 14:28:28 +0200 |
| commit | 3f1031c34ba840e2c1f6000d709ed4a6102b40a9 (patch) | |
| tree | 9db888e1a8291b0a1abc513f112ac3bf476bb27f /src | |
| parent | bfe2a353abba4620920cd99511b19780c8d341a2 (diff) | |
| download | luajit-3f1031c34ba840e2c1f6000d709ed4a6102b40a9.tar.gz luajit-3f1031c34ba840e2c1f6000d709ed4a6102b40a9.tar.bz2 luajit-3f1031c34ba840e2c1f6000d709ed4a6102b40a9.zip | |
Use MAP_TRYFIXED for the probing memory allocator, if available.
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. */ |
