From 9073acdc9888acd2ba66601a77b96fbda67ac8c7 Mon Sep 17 00:00:00 2001 From: Adam Reichold Date: Wed, 5 Aug 2020 16:56:51 +0200 Subject: [PATCH] Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX. --- library/std/src/sys/unix/fd.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/sys/unix/fd.rs b/library/std/src/sys/unix/fd.rs index 6b8f3ea172d..e36a53084ba 100644 --- a/library/std/src/sys/unix/fd.rs +++ b/library/std/src/sys/unix/fd.rs @@ -3,6 +3,7 @@ use crate::cmp; use crate::io::{self, Initializer, IoSlice, IoSliceMut, Read}; use crate::mem; +#[cfg(not(any(target_os = "redox", target_env = "newlib")))] use crate::sync::atomic::{AtomicUsize, Ordering}; use crate::sys::cvt; use crate::sys_common::AsInner; @@ -27,6 +28,7 @@ const READ_LIMIT: usize = c_int::MAX as usize - 1; #[cfg(not(target_os = "macos"))] const READ_LIMIT: usize = libc::ssize_t::MAX as usize; +#[cfg(not(any(target_os = "redox", target_env = "newlib")))] fn max_iov() -> usize { static LIM: AtomicUsize = AtomicUsize::new(0); @@ -42,6 +44,11 @@ fn max_iov() -> usize { lim } +#[cfg(any(target_os = "redox", target_env = "newlib"))] +fn max_iov() -> usize { + 16 // The minimum value required by POSIX. +} + impl FileDesc { pub fn new(fd: c_int) -> FileDesc { FileDesc { fd }