]> git.lizzy.rs Git - rust.git/commitdiff
Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX.
authorAdam Reichold <adam.reichold@t-online.de>
Wed, 5 Aug 2020 14:56:51 +0000 (16:56 +0200)
committerAdam Reichold <adam.reichold@t-online.de>
Wed, 5 Aug 2020 15:15:08 +0000 (17:15 +0200)
library/std/src/sys/unix/fd.rs

index 6b8f3ea172d0ed7b93bc07d6122487fcb9af9bbf..e36a53084bae1874a92be0ba1056e7edf691f899 100644 (file)
@@ -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 @@ pub struct FileDesc {
 #[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 }