Skip to content

Commit

Permalink
make the code compile when using uclibc
Browse files Browse the repository at this point in the history
  • Loading branch information
inglorion committed Jul 1, 2023
1 parent beb22da commit 10d3fea
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/sys/uio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ pub fn pwritev<Fd: AsFd, Off: Into<off_t>>(
iov: &[IoSlice<'_>],
offset: Off,
) -> Result<usize> {
let offset = offset.into();
// uclibc uses 64-bit offsets for pwritev even if it otherwise uses
// 32-bit file offsets.
#[cfg(target_env = "uclibc")]
let offset = offset as libc::off64_t; // uclibc doesn't use off_t
let offset = offset as libc::off64_t;

// SAFETY: same as in writev()
let res = unsafe {
largefile_fn![pwritev](
fd.as_fd().as_raw_fd(),
iov.as_ptr() as *const libc::iovec,
iov.len() as c_int,
offset.into(),
offset,
)
};

Expand All @@ -80,16 +83,19 @@ pub fn preadv<Fd: AsFd, Off: Into<off_t>>(
iov: &mut [IoSliceMut<'_>],
offset: Off,
) -> Result<usize> {
let offset = offset.into();
// uclibc uses 64-bit offsets for preadv even if it otherwise uses
// 32-bit file offsets.
#[cfg(target_env = "uclibc")]
let offset = offset as libc::off64_t; // uclibc doesn't use off_t
let offset = offset as libc::off64_t;

// SAFETY: same as in readv()
let res = unsafe {
largefile_fn![preadv](
fd.as_fd().as_raw_fd(),
iov.as_ptr() as *const libc::iovec,
iov.len() as c_int,
offset.into(),
offset,
)
};

Expand Down

0 comments on commit 10d3fea

Please sign in to comment.