Skip to content

Commit

Permalink
Unix: Support more platforms with preadv and pwritev
Browse files Browse the repository at this point in the history
  • Loading branch information
a1phyr committed Mar 22, 2024
1 parent eff958c commit c1c20f6
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions library/std/src/sys/pal/unix/fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,16 @@ impl FileDesc {
}

#[cfg(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
let ret = cvt(unsafe {
Expand All @@ -188,7 +191,9 @@ impl FileDesc {
}

#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
Expand All @@ -199,6 +204,8 @@ impl FileDesc {
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "watchos",
)))]
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
io::default_read_vectored(|b| self.read_at(b, offset), bufs)
Expand Down Expand Up @@ -239,6 +246,7 @@ impl FileDesc {
target_os = "ios",
target_os = "tvos",
target_os = "macos",
target_os = "watchos",
))]
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
super::weak::weak!(fn preadv64(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
Expand Down Expand Up @@ -318,13 +326,16 @@ impl FileDesc {
}

#[cfg(any(
target_os = "aix",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "hurd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
))]
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
let ret = cvt(unsafe {
Expand All @@ -339,7 +350,9 @@ impl FileDesc {
}

#[cfg(not(any(
target_os = "aix",
target_os = "android",
target_os = "dragonfly",
target_os = "emscripten",
target_os = "freebsd",
target_os = "fuchsia",
Expand All @@ -350,6 +363,8 @@ impl FileDesc {
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "watchos",
)))]
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
io::default_write_vectored(|b| self.write_at(b, offset), bufs)
Expand Down Expand Up @@ -390,6 +405,7 @@ impl FileDesc {
target_os = "ios",
target_os = "tvos",
target_os = "macos",
target_os = "watchos",
))]
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
super::weak::weak!(fn pwritev64(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
Expand Down

0 comments on commit c1c20f6

Please sign in to comment.