From 839c740cb1896fd3715cd271068ac1f8a286a2dd Mon Sep 17 00:00:00 2001 From: Eugen Wissner Date: Wed, 12 Jul 2017 10:04:48 +0200 Subject: [PATCH] Fix mmap flags on linux --- source/tanya/memory/mmappool.d | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/tanya/memory/mmappool.d b/source/tanya/memory/mmappool.d index 7e8dac9..9f59afc 100644 --- a/source/tanya/memory/mmappool.d +++ b/source/tanya/memory/mmappool.d @@ -18,6 +18,8 @@ import tanya.memory.allocator; version (Posix) { + import core.sys.posix.sys.mman : PROT_READ, PROT_WRITE, MAP_PRIVATE, + MAP_ANON, MAP_FAILED; import core.sys.posix.unistd; extern (C) @@ -35,11 +37,11 @@ version (Posix) { void* p = mmap(null, len, - 0x01 | 0x02, // PROT_READ | PROT_WRITE - 0x0002 | 0x1000, // MAP_PRIVATE | MAP_ANON + PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANON, -1, 0); - return p is (cast(void*) -1) ? null : p; + return p is MAP_FAILED ? null : p; } private bool unmapMemory(shared void* addr, const size_t len) @@ -311,7 +313,7 @@ final class MmapPool : Allocator * Returns: $(D_KEYWORD true) if successful, $(D_KEYWORD false) otherwise. */ bool reallocateInPlace(ref void[] p, const size_t size) - pure shared nothrow @nogc + shared pure nothrow @nogc { if (p is null || size == 0) {