Skip to content

Commit

Permalink
Using mmap64 instead of plain mmap on GNU.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvella committed Jun 24, 2023
1 parent 04178aa commit 93cc421
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const MAP_POPULATE: libc::c_int = libc::MAP_POPULATE;
#[cfg(not(any(target_os = "linux", target_os = "android")))]
const MAP_POPULATE: libc::c_int = 0;

#[cfg(target_env = "gnu")]
use libc::{mmap64 as mmap, off64_t as off_t};

#[cfg(not(target_env = "gnu"))]
use libc::{mmap, off_t};

pub struct MmapInner {
ptr: *mut libc::c_void,
len: usize,
Expand All @@ -50,13 +56,13 @@ impl MmapInner {
let (map_len, map_offset) = Self::adjust_mmap_params(len as usize, alignment as usize)?;

unsafe {
let ptr = libc::mmap(
let ptr = mmap(
ptr::null_mut(),
map_len as libc::size_t,
prot,
flags,
file,
aligned_offset as libc::off_t,
aligned_offset as off_t,
);

if ptr == libc::MAP_FAILED {
Expand Down

0 comments on commit 93cc421

Please sign in to comment.