Add fallback for cfg(unix) targets that do not define libc::_SC_IOV_MAX.

This commit is contained in:
Adam Reichold 2020-08-05 16:56:51 +02:00
parent 04a0114e7e
commit 9073acdc98

View 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 @@ 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 }