Skip to content

Commit 92f35b3

Browse files
committed
Use weak linkage for preadv and pwritev on MacOS and iOS
1 parent 23cd4ce commit 92f35b3

File tree

1 file changed

+18
-8
lines changed
  • library/std/src/sys/unix

1 file changed

+18
-8
lines changed

library/std/src/sys/unix/fd.rs

+18-8
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ impl FileDesc {
152152
target_os = "freebsd",
153153
target_os = "fuchsia",
154154
target_os = "illumos",
155-
target_os = "ios",
156155
target_os = "linux",
157-
target_os = "macos",
158156
target_os = "netbsd",
159157
))]
160158
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
@@ -170,6 +168,7 @@ impl FileDesc {
170168
}
171169

172170
#[cfg(not(any(
171+
target_os = "android",
173172
target_os = "emscripten",
174173
target_os = "freebsd",
175174
target_os = "fuchsia",
@@ -188,7 +187,7 @@ impl FileDesc {
188187
//
189188
// On 32-bit targets, we don't want to deal with weird ABI issues around
190189
// passing 64-bits parameters to syscalls, so we fallback to the default
191-
// implementation.
190+
// implementation if `preadv` is not available.
192191
#[cfg(all(target_os = "android", target_pointer_width = "64"))]
193192
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
194193
super::weak::syscall! {
@@ -211,7 +210,13 @@ impl FileDesc {
211210
Ok(ret as usize)
212211
}
213212

214-
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
213+
// We support old MacOS and iOS versions that do not have `preadv`. There is
214+
// no `syscall` possible in these platform.
215+
#[cfg(any(
216+
all(target_os = "android", target_pointer_width = "32"),
217+
target_os = "ios",
218+
target_os = "macos",
219+
))]
215220
pub fn read_vectored_at(&self, bufs: &mut [IoSliceMut<'_>], offset: u64) -> io::Result<usize> {
216221
super::weak::weak!(fn preadv64(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
217222

@@ -286,9 +291,7 @@ impl FileDesc {
286291
target_os = "freebsd",
287292
target_os = "fuchsia",
288293
target_os = "illumos",
289-
target_os = "ios",
290294
target_os = "linux",
291-
target_os = "macos",
292295
target_os = "netbsd",
293296
))]
294297
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
@@ -304,6 +307,7 @@ impl FileDesc {
304307
}
305308

306309
#[cfg(not(any(
310+
target_os = "android",
307311
target_os = "emscripten",
308312
target_os = "freebsd",
309313
target_os = "fuchsia",
@@ -322,7 +326,7 @@ impl FileDesc {
322326
//
323327
// On 32-bit targets, we don't want to deal with weird ABI issues around
324328
// passing 64-bits parameters to syscalls, so we fallback to the default
325-
// implementation.
329+
// implementation if `pwritev` is not available.
326330
#[cfg(all(target_os = "android", target_pointer_width = "64"))]
327331
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
328332
super::weak::syscall! {
@@ -345,7 +349,13 @@ impl FileDesc {
345349
Ok(ret as usize)
346350
}
347351

348-
#[cfg(all(target_os = "android", target_pointer_width = "32"))]
352+
// We support old MacOS and iOS versions that do not have `pwritev`. There is
353+
// no `syscall` possible in these platform.
354+
#[cfg(any(
355+
all(target_os = "android", target_pointer_width = "32"),
356+
target_os = "ios",
357+
target_os = "macos",
358+
))]
349359
pub fn write_vectored_at(&self, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
350360
super::weak::weak!(fn pwritev64(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
351361

0 commit comments

Comments
 (0)