Function mlock2 [src]
Prototype
pub fn mlock2(memory: []align(page_size_min) const u8, flags: MLOCK) MlockError!void Parameters
memory: []align(page_size_min) const u8flags: MLOCK Possible Errors
The Operating System returned an undocumented error code.
This error is in theory not possible, but it would be better to handle this error than to invoke undefined behavior.
When this error code is observed, it usually means the Zig Standard Library needs a small patch to add the error code to the error set for the respective function.
Source
pub fn mlock2(memory: []align(page_size_min) const u8, flags: MLOCK) MlockError!void {
if (@TypeOf(system.mlock2) == void)
@compileError("mlock2 not supported on this OS");
return switch (errno(system.mlock2(memory.ptr, memory.len, flags))) {
.SUCCESS => {},
.INVAL => unreachable, // bad memory or bad flags
.PERM => error.PermissionDenied,
.NOMEM => error.LockedMemoryLimitExceeded,
.AGAIN => error.SystemResources,
else => |err| unexpectedErrno(err),
};
}