@@ -7,7 +7,6 @@ use crate::cmp;
77use crate :: io:: { self , Initializer , IoSlice , IoSliceMut , Read } ;
88use crate :: mem;
99#[ cfg( not( any( target_os = "redox" , target_env = "newlib" ) ) ) ]
10- use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
1110use crate :: sys:: cvt;
1211use crate :: sys_common:: AsInner ;
1312
@@ -31,24 +30,35 @@ const READ_LIMIT: usize = c_int::MAX as usize - 1;
3130#[ cfg( not( target_os = "macos" ) ) ]
3231const READ_LIMIT : usize = libc:: ssize_t:: MAX as usize ;
3332
34- #[ cfg( not( any( target_os = "redox" , target_env = "newlib" ) ) ) ]
35- fn max_iov ( ) -> usize {
36- static LIM : AtomicUsize = AtomicUsize :: new ( 0 ) ;
37-
38- let mut lim = LIM . load ( Ordering :: Relaxed ) ;
39- if lim == 0 {
40- let ret = unsafe { libc:: sysconf ( libc:: _SC_IOV_MAX) } ;
41-
42- // 16 is the minimum value required by POSIX.
43- lim = if ret > 0 { ret as usize } else { 16 } ;
44- LIM . store ( lim, Ordering :: Relaxed ) ;
45- }
33+ #[ cfg( any(
34+ target_os = "dragonfly" ,
35+ target_os = "freebsd" ,
36+ target_os = "ios" ,
37+ target_os = "macos" ,
38+ target_os = "netbsd" ,
39+ target_os = "openbsd" ,
40+ ) ) ]
41+ const fn max_iov ( ) -> usize {
42+ libc:: IOV_MAX as usize
43+ }
4644
47- lim
45+ #[ cfg( any( target_os = "android" , target_os = "emscripten" , target_os = "linux" ) ) ]
46+ const fn max_iov ( ) -> usize {
47+ libc:: UIO_MAXIOV as usize
4848}
4949
50- #[ cfg( any( target_os = "redox" , target_env = "newlib" ) ) ]
51- fn max_iov ( ) -> usize {
50+ #[ cfg( not( any(
51+ target_os = "android" ,
52+ target_os = "dragonfly" ,
53+ target_os = "emscripten" ,
54+ target_os = "freebsd" ,
55+ target_os = "ios" ,
56+ target_os = "linux" ,
57+ target_os = "macos" ,
58+ target_os = "netbsd" ,
59+ target_os = "openbsd" ,
60+ ) ) ) ]
61+ const fn max_iov ( ) -> usize {
5262 16 // The minimum value required by POSIX.
5363}
5464
0 commit comments