Skip to content

Commit 688cfe2

Browse files
committed
adding map_aligned feature separately, in case.
1 parent 346c22f commit 688cfe2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/sys/mman.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,3 +637,13 @@ pub fn shm_unlink<P: ?Sized + NixPath>(name: &P) -> Result<()> {
637637

638638
Errno::result(ret).map(drop)
639639
}
640+
641+
/// Matches BSD's `MAP_ALIGNED(x)` macro, x being ilog2(alignment).
642+
///
643+
/// For more information, see [`mmap(2)`].
644+
///
645+
/// [`mmap(2)`]: https://man.freebsd.org/cgi/man.cgi?mmap(2)
646+
#[cfg(any(target_os = "netbsd", target_os = "freebsd"))]
647+
pub const fn map_aligned(v: u32) -> u32 {
648+
v << MapFlags::MAP_ALIGNMENT_SHIFT.bits()
649+
}

0 commit comments

Comments
 (0)