Skip to content

Commit

Permalink
Add freebsd support: Add MAP_FIXED to mmap call.
Browse files Browse the repository at this point in the history
The codeblock fails on freebsd unless MAP_FIXED is
explicitly set.
  • Loading branch information
basicinside authored and bastibl committed Sep 1, 2023
1 parent e348094 commit 3d03515
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/double_mapped_buffer/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ impl DoubleMappedBufferImpl {
return Err(DoubleMappedBufferError::UnmapSecond);
}

#[cfg(target_os = "freebsd")]
let buff2 = libc::mmap(
buff.add(size),
size,
libc::PROT_READ | libc::PROT_WRITE,
libc::MAP_SHARED | libc::MAP_FIXED,
fd,
0,
);
#[cfg(not(target_os = "freebsd"))]
let buff2 = libc::mmap(
buff.add(size),
size,
Expand Down

0 comments on commit 3d03515

Please sign in to comment.