From 079bf8f885f45aa3ac9ede51ccc96240f0aa3268 Mon Sep 17 00:00:00 2001 From: Andreas Fackler Date: Tue, 27 Mar 2018 16:24:14 +0200 Subject: [PATCH] add docs for memory locking functions --- src/sys/mman.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sys/mman.rs b/src/sys/mman.rs index 4aac67ac32..ce0d0cc878 100644 --- a/src/sys/mman.rs +++ b/src/sys/mman.rs @@ -215,18 +215,25 @@ libc_bitflags!{ } } +/// Locks all memory pages that contain part of the address range with `length` bytes starting at +/// `addr`. Locked pages never move to the swap area. pub unsafe fn mlock(addr: *const c_void, length: size_t) -> Result<()> { Errno::result(libc::mlock(addr, length)).map(drop) } +/// Unlocks all memory pages that contain part of the address range with `length` bytes starting at +/// `addr`. pub unsafe fn munlock(addr: *const c_void, length: size_t) -> Result<()> { Errno::result(libc::munlock(addr, length)).map(drop) } +/// Locks all memory pages mapped into this process' address space. Locked pages never move to the +/// swap area. pub fn mlockall(flags: MlockAllFlags) -> Result<()> { unsafe { Errno::result(libc::mlockall(flags.bits())) }.map(drop) } +/// Unocks all memory pages mapped into this process' address space. pub fn munlockall() -> Result<()> { unsafe { Errno::result(libc::munlockall()) }.map(drop) }