Skip to content

Commit 81d8744

Browse files
authored
Add MCL_ONFAULT constant to libc backend (#920)
1 parent 01585f5 commit 81d8744

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/backend/libc/mm/types.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,17 @@ bitflags! {
451451
#[repr(transparent)]
452452
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
453453
pub struct MlockAllFlags: u32 {
454-
// libc doesn't define `MCL_ONFAULT` yet.
455-
// const ONFAULT = libc::MCL_ONFAULT;
454+
/// Used together with `MCL_CURRENT`, `MCL_FUTURE`, or both. Mark all
455+
/// current (with `MCL_CURRENT`) or future (with `MCL_FUTURE`) mappings
456+
/// to lock pages when they are faulted in. When used with
457+
/// `MCL_CURRENT`, all present pages are locked, but `mlockall` will
458+
/// not fault in non-present pages. When used with `MCL_FUTURE`, all
459+
/// future mappings will be marked to lock pages when they are faulted
460+
/// in, but they will not be populated by the lock when the mapping is
461+
/// created. `MCL_ONFAULT` must be used with either `MCL_CURRENT` or
462+
/// `MCL_FUTURE` or both.
463+
#[cfg(linux_kernel)]
464+
const ONFAULT = bitcast!(libc::MCL_ONFAULT);
456465
/// Lock all pages which will become mapped into the address space of
457466
/// the process in the future. These could be, for instance, new pages
458467
/// required by a growing heap and stack as well as new memory-mapped

0 commit comments

Comments
 (0)