(
addr: *mut c_void,
length: usize,
prot: ProtFlags,
flags: MapFlags,
fd: BorrowedFd<'_>,
offset: u64,
)
| 42 | /// with memory pointed to by raw pointers is unsafe. |
| 43 | #[inline] |
| 44 | pub(crate) unsafe fn mmap( |
| 45 | addr: *mut c_void, |
| 46 | length: usize, |
| 47 | prot: ProtFlags, |
| 48 | flags: MapFlags, |
| 49 | fd: BorrowedFd<'_>, |
| 50 | offset: u64, |
| 51 | ) -> io::Result<*mut c_void> { |
| 52 | #[cfg(target_pointer_width = "32")] |
| 53 | { |
| 54 | ret_void_star(syscall!( |
| 55 | __NR_mmap2, |
| 56 | addr, |
| 57 | pass_usize(length), |
| 58 | prot, |
| 59 | flags, |
| 60 | fd, |
| 61 | (offset / 4096) |
| 62 | .try_into() |
| 63 | .map(pass_usize) |
| 64 | .map_err(|_| io::Errno::INVAL)? |
| 65 | )) |
| 66 | } |
| 67 | #[cfg(target_pointer_width = "64")] |
| 68 | { |
| 69 | ret_void_star(syscall!( |
| 70 | __NR_mmap, |
| 71 | addr, |
| 72 | pass_usize(length), |
| 73 | prot, |
| 74 | flags, |
| 75 | fd, |
| 76 | loff_t_from_u64(offset) |
| 77 | )) |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /// # Safety |
| 82 | /// |
nothing calls this directly
no test coverage detected