@@ -7,7 +7,6 @@ use crate::cmp;
7
7
use crate :: io:: { self , Initializer , IoSlice , IoSliceMut , Read } ;
8
8
use crate :: mem;
9
9
#[ cfg( not( any( target_os = "redox" , target_env = "newlib" ) ) ) ]
10
- use crate :: sync:: atomic:: { AtomicUsize , Ordering } ;
11
10
use crate :: sys:: cvt;
12
11
use crate :: sys_common:: AsInner ;
13
12
@@ -31,24 +30,35 @@ const READ_LIMIT: usize = c_int::MAX as usize - 1;
31
30
#[ cfg( not( target_os = "macos" ) ) ]
32
31
const READ_LIMIT : usize = libc:: ssize_t:: MAX as usize ;
33
32
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
+ }
46
44
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
48
48
}
49
49
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 {
52
62
16 // The minimum value required by POSIX.
53
63
}
54
64
0 commit comments