Skip to content

Commit

Permalink
mmap addr
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Nov 19, 2022
1 parent fbebb21 commit 9793c7f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/sys/mman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,14 +417,19 @@ pub fn munlockall() -> Result<()> {
///
/// [`mmap(2)`]: https://man7.org/linux/man-pages/man2/mmap.2.html
pub unsafe fn mmap(
addr: *mut c_void,
addr: Option<size_t>,
length: size_t,
prot: ProtFlags,
flags: MapFlags,
fd: RawFd,
offset: off_t,
) -> Result<*mut c_void> {
let ret = libc::mmap(addr, length, prot.bits(), flags.bits(), fd, offset);
let ptr = addr.map_or(
std::ptr::null_mut(),
|a| a as *mut c_void
);

let ret = libc::mmap(ptr, length, prot.bits(), flags.bits(), fd, offset);

if ret == libc::MAP_FAILED {
Err(Errno::last())
Expand Down

0 comments on commit 9793c7f

Please sign in to comment.