Skip to content

Commit 10d3fea

Browse files
committed
make the code compile when using uclibc
1 parent beb22da commit 10d3fea

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/sys/uio.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,19 @@ pub fn pwritev<Fd: AsFd, Off: Into<off_t>>(
5050
iov: &[IoSlice<'_>],
5151
offset: Off,
5252
) -> Result<usize> {
53+
let offset = offset.into();
54+
// uclibc uses 64-bit offsets for pwritev even if it otherwise uses
55+
// 32-bit file offsets.
5356
#[cfg(target_env = "uclibc")]
54-
let offset = offset as libc::off64_t; // uclibc doesn't use off_t
57+
let offset = offset as libc::off64_t;
5558

5659
// SAFETY: same as in writev()
5760
let res = unsafe {
5861
largefile_fn![pwritev](
5962
fd.as_fd().as_raw_fd(),
6063
iov.as_ptr() as *const libc::iovec,
6164
iov.len() as c_int,
62-
offset.into(),
65+
offset,
6366
)
6467
};
6568

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

8692
// SAFETY: same as in readv()
8793
let res = unsafe {
8894
largefile_fn![preadv](
8995
fd.as_fd().as_raw_fd(),
9096
iov.as_ptr() as *const libc::iovec,
9197
iov.len() as c_int,
92-
offset.into(),
98+
offset,
9399
)
94100
};
95101

0 commit comments

Comments
 (0)