@@ -13,16 +13,17 @@ use std::marker::PhantomData;
13
13
use std:: mem:: { self , size_of, MaybeUninit } ;
14
14
use std:: net:: Shutdown ;
15
15
use std:: net:: { Ipv4Addr , Ipv6Addr } ;
16
- #[ cfg( all( feature = "all" , target_vendor = "apple" ) ) ]
16
+ #[ cfg( all( feature = "all" , any ( target_os = "ios" , target_os = "macos" ) ) ) ]
17
17
use std:: num:: NonZeroU32 ;
18
18
#[ cfg( all(
19
19
feature = "all" ,
20
20
any(
21
21
target_os = "aix" ,
22
22
target_os = "android" ,
23
23
target_os = "freebsd" ,
24
+ target_os = "ios" ,
24
25
target_os = "linux" ,
25
- target_vendor = "apple " ,
26
+ target_os = "macos " ,
26
27
)
27
28
) ) ]
28
29
use std:: num:: NonZeroUsize ;
@@ -33,8 +34,9 @@ use std::os::unix::ffi::OsStrExt;
33
34
target_os = "aix" ,
34
35
target_os = "android" ,
35
36
target_os = "freebsd" ,
37
+ target_os = "ios" ,
36
38
target_os = "linux" ,
37
- target_vendor = "apple " ,
39
+ target_os = "macos " ,
38
40
)
39
41
) ) ]
40
42
use std:: os:: unix:: io:: RawFd ;
@@ -46,7 +48,7 @@ use std::ptr;
46
48
use std:: time:: { Duration , Instant } ;
47
49
use std:: { io, slice} ;
48
50
49
- #[ cfg( not( target_vendor = "apple" ) ) ]
51
+ #[ cfg( not( any ( target_os = "ios" , target_os = "macos" ) ) ) ]
50
52
use libc:: ssize_t;
51
53
use libc:: { in6_addr, in_addr} ;
52
54
@@ -117,9 +119,9 @@ pub(crate) use libc::IP_RECVTOS;
117
119
target_os = "illumos" ,
118
120
) ) ) ]
119
121
pub ( crate ) use libc:: IP_TOS ;
120
- #[ cfg( not( target_vendor = "apple" ) ) ]
122
+ #[ cfg( not( any ( target_os = "ios" , target_os = "macos" ) ) ) ]
121
123
pub ( crate ) use libc:: SO_LINGER ;
122
- #[ cfg( target_vendor = "apple" ) ]
124
+ #[ cfg( any ( target_os = "ios" , target_os = "macos" ) ) ]
123
125
pub ( crate ) use libc:: SO_LINGER_SEC as SO_LINGER ;
124
126
pub ( crate ) use libc:: {
125
127
ip_mreq as IpMreq , linger, IPPROTO_IP , IPPROTO_IPV6 , IPV6_MULTICAST_HOPS , IPV6_MULTICAST_IF ,
@@ -145,22 +147,24 @@ pub(crate) use libc::{
145
147
target_os = "freebsd" ,
146
148
target_os = "haiku" ,
147
149
target_os = "illumos" ,
150
+ target_os = "ios" ,
151
+ target_os = "macos" ,
148
152
target_os = "netbsd" ,
153
+ target_os = "nto" ,
149
154
target_os = "openbsd" ,
150
155
target_os = "solaris" ,
151
- target_os = "nto" ,
152
- target_vendor = "apple"
153
156
) ) ) ]
154
157
pub ( crate ) use libc:: { IPV6_ADD_MEMBERSHIP , IPV6_DROP_MEMBERSHIP } ;
155
158
#[ cfg( any(
156
159
target_os = "dragonfly" ,
157
160
target_os = "freebsd" ,
158
161
target_os = "haiku" ,
159
162
target_os = "illumos" ,
163
+ target_os = "ios" ,
164
+ target_os = "macos" ,
160
165
target_os = "netbsd" ,
161
166
target_os = "openbsd" ,
162
167
target_os = "solaris" ,
163
- target_vendor = "apple" ,
164
168
) ) ]
165
169
pub ( crate ) use libc:: {
166
170
IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP , IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP ,
@@ -173,23 +177,25 @@ pub(crate) use libc::{
173
177
target_os = "freebsd" ,
174
178
target_os = "fuchsia" ,
175
179
target_os = "illumos" ,
180
+ target_os = "ios" ,
176
181
target_os = "linux" ,
182
+ target_os = "macos" ,
177
183
target_os = "netbsd" ,
178
- target_vendor = "apple" ,
179
184
)
180
185
) ) ]
181
186
pub ( crate ) use libc:: { TCP_KEEPCNT , TCP_KEEPINTVL } ;
182
187
183
188
// See this type in the Windows file.
184
189
pub ( crate ) type Bool = c_int ;
185
190
186
- #[ cfg( any( target_vendor = "apple " , target_os = "nto" ) ) ]
191
+ #[ cfg( any( target_os = "ios" , target_os = "macos ", target_os = "nto" ) ) ]
187
192
use libc:: TCP_KEEPALIVE as KEEPALIVE_TIME ;
188
193
#[ cfg( not( any(
189
- target_vendor = "apple" ,
190
194
target_os = "haiku" ,
191
- target_os = "openbsd" ,
195
+ target_os = "ios" ,
196
+ target_os = "macos" ,
192
197
target_os = "nto" ,
198
+ target_os = "openbsd" ,
193
199
) ) ) ]
194
200
use libc:: TCP_KEEPIDLE as KEEPALIVE_TIME ;
195
201
@@ -207,7 +213,7 @@ macro_rules! syscall {
207
213
}
208
214
209
215
/// Maximum size of a buffer passed to system call like `recv` and `send`.
210
- #[ cfg( not( target_vendor = "apple" ) ) ]
216
+ #[ cfg( not( any ( target_os = "ios" , target_os = "macos" ) ) ) ]
211
217
const MAX_BUF_LEN : usize = ssize_t:: MAX as usize ;
212
218
213
219
// The maximum read limit on most posix-like systems is `SSIZE_MAX`, with the
@@ -218,7 +224,7 @@ const MAX_BUF_LEN: usize = ssize_t::MAX as usize;
218
224
// intentionally showing odd behavior by rejecting any read with a size larger
219
225
// than or equal to INT_MAX. To handle both of these the read size is capped on
220
226
// both platforms.
221
- #[ cfg( target_vendor = "apple" ) ]
227
+ #[ cfg( any ( target_os = "ios" , target_os = "macos" ) ) ]
222
228
const MAX_BUF_LEN : usize = c_int:: MAX as usize - 1 ;
223
229
224
230
// TCP_CA_NAME_MAX isn't defined in user space include files(not in libc)
@@ -251,11 +257,12 @@ type IovLen = usize;
251
257
target_os = "fuchsia" ,
252
258
target_os = "haiku" ,
253
259
target_os = "illumos" ,
260
+ target_os = "ios" ,
261
+ target_os = "macos" ,
254
262
target_os = "netbsd" ,
263
+ target_os = "nto" ,
255
264
target_os = "openbsd" ,
256
265
target_os = "solaris" ,
257
- target_os = "nto" ,
258
- target_vendor = "apple" ,
259
266
) ) ]
260
267
type IovLen = c_int ;
261
268
@@ -939,9 +946,10 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
939
946
target_os = "freebsd" ,
940
947
target_os = "fuchsia" ,
941
948
target_os = "illumos" ,
949
+ target_os = "ios" ,
942
950
target_os = "linux" ,
951
+ target_os = "macos" ,
943
952
target_os = "netbsd" ,
944
- target_vendor = "apple" ,
945
953
) ) ]
946
954
{
947
955
if let Some ( interval) = keepalive. interval {
@@ -1177,13 +1185,16 @@ impl crate::Socket {
1177
1185
}
1178
1186
1179
1187
/// Sets `SO_NOSIGPIPE` on the socket.
1180
- #[ cfg( all( feature = "all" , target_vendor = "apple" ) ) ]
1181
- #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_vendor = "apple" ) ) ) ) ]
1188
+ #[ cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) ]
1189
+ #[ cfg_attr(
1190
+ docsrs,
1191
+ doc( cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) )
1192
+ ) ]
1182
1193
pub fn set_nosigpipe ( & self , nosigpipe : bool ) -> io:: Result < ( ) > {
1183
1194
self . _set_nosigpipe ( nosigpipe)
1184
1195
}
1185
1196
1186
- #[ cfg( target_vendor = "apple" ) ]
1197
+ #[ cfg( any ( target_os = "ios" , target_os = "macos" ) ) ]
1187
1198
pub ( crate ) fn _set_nosigpipe ( & self , nosigpipe : bool ) -> io:: Result < ( ) > {
1188
1199
unsafe {
1189
1200
setsockopt (
@@ -1621,8 +1632,11 @@ impl crate::Socket {
1621
1632
///
1622
1633
/// One can use [`libc::if_nametoindex`] to convert an interface alias to an
1623
1634
/// index.
1624
- #[ cfg( all( feature = "all" , target_vendor = "apple" ) ) ]
1625
- #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_vendor = "apple" ) ) ) ) ]
1635
+ #[ cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) ]
1636
+ #[ cfg_attr(
1637
+ docsrs,
1638
+ doc( cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) )
1639
+ ) ]
1626
1640
pub fn bind_device_by_index ( & self , interface : Option < NonZeroU32 > ) -> io:: Result < ( ) > {
1627
1641
let index = interface. map_or ( 0 , NonZeroU32 :: get) ;
1628
1642
unsafe { setsockopt ( self . as_raw ( ) , IPPROTO_IP , libc:: IP_BOUND_IF , index) }
@@ -1633,8 +1647,11 @@ impl crate::Socket {
1633
1647
///
1634
1648
/// Returns `None` if the socket is not bound to any interface, otherwise
1635
1649
/// returns an interface index.
1636
- #[ cfg( all( feature = "all" , target_vendor = "apple" ) ) ]
1637
- #[ cfg_attr( docsrs, doc( cfg( all( feature = "all" , target_vendor = "apple" ) ) ) ) ]
1650
+ #[ cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) ]
1651
+ #[ cfg_attr(
1652
+ docsrs,
1653
+ doc( cfg( all( feature = "all" , any( target_os = "ios" , target_os = "macos" ) ) ) )
1654
+ ) ]
1638
1655
pub fn device_index ( & self ) -> io:: Result < Option < NonZeroU32 > > {
1639
1656
let index =
1640
1657
unsafe { getsockopt :: < libc:: c_uint > ( self . as_raw ( ) , IPPROTO_IP , libc:: IP_BOUND_IF ) ? } ;
@@ -1921,8 +1938,9 @@ impl crate::Socket {
1921
1938
target_os = "aix" ,
1922
1939
target_os = "android" ,
1923
1940
target_os = "freebsd" ,
1941
+ target_os = "ios" ,
1924
1942
target_os = "linux" ,
1925
- target_vendor = "apple " ,
1943
+ target_os = "macos " ,
1926
1944
)
1927
1945
) ) ]
1928
1946
#[ cfg_attr(
@@ -1933,8 +1951,9 @@ impl crate::Socket {
1933
1951
target_os = "aix" ,
1934
1952
target_os = "android" ,
1935
1953
target_os = "freebsd" ,
1954
+ target_os = "ios" ,
1936
1955
target_os = "linux" ,
1937
- target_vendor = "apple " ,
1956
+ target_os = "macos " ,
1938
1957
)
1939
1958
) ) )
1940
1959
) ]
@@ -1950,7 +1969,7 @@ impl crate::Socket {
1950
1969
self . _sendfile ( file. as_raw_fd ( ) , offset as _ , length)
1951
1970
}
1952
1971
1953
- #[ cfg( all( feature = "all" , target_vendor = "apple" ) ) ]
1972
+ #[ cfg( all( feature = "all" , any ( target_os = "ios" , target_os = "macos" ) ) ) ]
1954
1973
fn _sendfile (
1955
1974
& self ,
1956
1975
file : RawFd ,
0 commit comments