diff --git a/src/lib.rs b/src/lib.rs index 0d64d2b6..2d730ae9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -482,7 +482,7 @@ impl MmapOptions { )); } - MmapInner::map_anon(len, self.stack).map(|inner| MmapMut { inner }) + MmapInner::map_anon(len, self.stack, self.populate).map(|inner| MmapMut { inner }) } /// Creates a raw memory map. diff --git a/src/stub.rs b/src/stub.rs index e756da4f..3c6af0e7 100644 --- a/src/stub.rs +++ b/src/stub.rs @@ -36,7 +36,7 @@ impl MmapInner { MmapInner::new() } - pub fn map_anon(_: usize, _: bool) -> io::Result { + pub fn map_anon(_: usize, _: bool, _: bool) -> io::Result { MmapInner::new() } diff --git a/src/unix.rs b/src/unix.rs index f691e680..221d3ba8 100644 --- a/src/unix.rs +++ b/src/unix.rs @@ -162,12 +162,13 @@ impl MmapInner { } /// Open an anonymous memory map. - pub fn map_anon(len: usize, stack: bool) -> io::Result { + pub fn map_anon(len: usize, stack: bool, populate: bool) -> io::Result { let stack = if stack { MAP_STACK } else { 0 }; + let populate = if populate { MAP_POPULATE } else { 0 }; MmapInner::new( len, libc::PROT_READ | libc::PROT_WRITE, - libc::MAP_PRIVATE | libc::MAP_ANON | stack, + libc::MAP_PRIVATE | libc::MAP_ANON | stack | populate, -1, 0, ) diff --git a/src/windows.rs b/src/windows.rs index d580995e..c1b1a4d9 100644 --- a/src/windows.rs +++ b/src/windows.rs @@ -340,7 +340,7 @@ impl MmapInner { Ok(inner) } - pub fn map_anon(len: usize, _stack: bool) -> io::Result { + pub fn map_anon(len: usize, _stack: bool, _populate: bool) -> io::Result { // Ensure a non-zero length for the underlying mapping let mapped_len = len.max(1); unsafe {