| 1 |
//! The `msync` function. |
| 2 |
//! |
| 3 |
//! # Safety |
| 4 |
//! |
| 5 |
//! `msync` operates on a raw pointer. Some forms of `msync` may mutate the |
| 6 |
//! memory or have other side effects. |
| 7 |
#![allow(unsafe_code)] |
| 8 |
|
| 9 |
use crate::{backend, io}; |
| 10 |
use core::ffi::c_void; |
| 11 |
|
| 12 |
pub use backend::mm::types::MsyncFlags; |
| 13 |
|
| 14 |
/// `msync(addr, len, flags)`—Synchronizes a memory-mapping with its backing |
| 15 |
/// storage. |
| 16 |
/// |
| 17 |
/// # Safety |
| 18 |
/// |
| 19 |
/// `addr` must be a valid pointer to memory that is appropriate to call |
| 20 |
/// `msync` on. Some forms of `msync` may mutate the memory or evoke a variety |
| 21 |
/// of side-effects on the mapping and/or the file. |
| 22 |
/// |
| 23 |
/// # References |
| 24 |
/// - [POSIX] |
| 25 |
/// - [Linux] |
| 26 |
/// - [Apple] |
| 27 |
/// - [FreeBSD] |
| 28 |
/// - [NetBSD] |
| 29 |
/// - [OpenBSD] |
| 30 |
/// - [DragonFly BSD] |
| 31 |
/// - [illumos] |
| 32 |
/// - [glibc] |
| 33 |
/// |
| 34 |
/// [POSIX]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/msync.html |
| 35 |
/// [Linux]: https://man7.org/linux/man-pages/man2/msync.2.html |
| 36 |
/// [Apple]: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man2/msync.2.html |
| 37 |
/// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=msync&sektion=2 |
| 38 |
/// [NetBSD]: https://man.netbsd.org/msync.2 |
| 39 |
/// [OpenBSD]: https://man.openbsd.org/msync.2 |
| 40 |
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=msync§ion=2 |
| 41 |
/// [illumos]: https://illumos.org/man/3C/msync |
| 42 |
/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Memory_002dmapped-I_002fO.html#index-msync |
| 43 |
#[inline] |
| 44 |
pub unsafe fn msync(addr: *mut c_void, len: usize, flags: MsyncFlags) -> io::Result<()> { |
| 45 |
backend::mm::syscalls::msync(addr, len, flags) |
| 46 |
} |