mlock2 is Linux‐only and exists since Linux 4.4 On Linux pre‐4.4 and other platforms fail with ENOSYS. glibc added the mlock2 wrapper in 2.27 https://lists.gnu.org/archive/html/info‐gnu/2018‐02/msg00000.html
Synopsis
Declared in <folly/system/MemoryMapping.h>
int
mlock2wrapper(
void const* addr,
size_t len,
MemoryMapping::LockFlags flags);
Return Value
0 on success, or ‐1 with errno set on failure.
Parameters
Name |
Description |
addr |
Start address of the range to lock. |
len |
Length in bytes of the range to lock. |
flags |
Locking flags passed to |
Created with MrDocs