pub fn madvise(ptr: [*]align(page_size_min) u8, length: usize, advice: u32) MadviseError!void ptr: [*]align(page_size_min) u8length: usizeadvice: u32AccessDeniedadvice is MADV.REMOVE, but the specified address range is not a shared writable mapping.
PermissionDeniedadvice is MADV.HWPOISON, but the caller does not have the CAP_SYS_ADMIN capability.
SystemResourcesA kernel resource was temporarily unavailable.
InvalidSyscallOne of the following:
WouldExceedMaximumResidentSetSize(for MADV.WILLNEED) Paging in this area would exceed the process's maximum resident set size.
OutOfMemoryOne of the following:
MadviseUnavailableThe madvise syscall is not available on this version and configuration of the Linux kernel.
UnexpectedThe operating system returned an undocumented error code.
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421pub fn madvise(ptr: [*]align(page_size_min) u8, length: usize, advice: u32) MadviseError!void {
switch (errno(system.madvise(ptr, length, advice))) {
.SUCCESS => return,
.PERM => return error.PermissionDenied,
.ACCES => return error.AccessDenied,
.AGAIN => return error.SystemResources,
.BADF => unreachable, // The map exists, but the area maps something that isn't a file.
.INVAL => return error.InvalidSyscall,
.IO => return error.WouldExceedMaximumResidentSetSize,
.NOMEM => return error.OutOfMemory,
.NOSYS => return error.MadviseUnavailable,
else => |err| return unexpectedErrno(err),
}
}
Give advice about use of memory. This syscall is optional and is sometimes configured to be disabled.