From 3d0351533b20e353bc962701da6fc158d690ad6a Mon Sep 17 00:00:00 2001 From: Robin Kuck Date: Wed, 30 Aug 2023 10:54:02 +0200 Subject: [PATCH] Add freebsd support: Add MAP_FIXED to mmap call. The codeblock fails on freebsd unless MAP_FIXED is explicitly set. --- src/double_mapped_buffer/unix.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/double_mapped_buffer/unix.rs b/src/double_mapped_buffer/unix.rs index fb069f7..2c641ec 100644 --- a/src/double_mapped_buffer/unix.rs +++ b/src/double_mapped_buffer/unix.rs @@ -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,