Skip to content

Commit a23db24

Browse files
committed
Remove usage of target_vendor = "apple"
Being deprecated, see: * <rust-lang/lang-team#102> * <rust-lang/rust#100343>
1 parent 8ca4091 commit a23db24

File tree

4 files changed

+91
-52
lines changed

4 files changed

+91
-52
lines changed

src/lib.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -475,10 +475,11 @@ impl TcpKeepalive {
475475
target_os = "freebsd",
476476
target_os = "fuchsia",
477477
target_os = "illumos",
478+
target_os = "ios",
478479
target_os = "linux",
480+
target_os = "macos",
479481
target_os = "netbsd",
480-
target_vendor = "apple",
481-
windows,
482+
target_os = "windows",
482483
)
483484
))]
484485
#[cfg_attr(
@@ -491,10 +492,11 @@ impl TcpKeepalive {
491492
target_os = "freebsd",
492493
target_os = "fuchsia",
493494
target_os = "illumos",
495+
target_os = "ios",
494496
target_os = "linux",
497+
target_os = "macos",
495498
target_os = "netbsd",
496-
target_vendor = "apple",
497-
windows,
499+
target_os = "windows",
498500
)
499501
)))
500502
)]
@@ -517,9 +519,10 @@ impl TcpKeepalive {
517519
target_os = "freebsd",
518520
target_os = "fuchsia",
519521
target_os = "illumos",
522+
target_os = "ios",
520523
target_os = "linux",
524+
target_os = "macos",
521525
target_os = "netbsd",
522-
target_vendor = "apple",
523526
)
524527
))]
525528
#[cfg_attr(
@@ -532,9 +535,10 @@ impl TcpKeepalive {
532535
target_os = "freebsd",
533536
target_os = "fuchsia",
534537
target_os = "illumos",
538+
target_os = "ios",
535539
target_os = "linux",
540+
target_os = "macos",
536541
target_os = "netbsd",
537-
target_vendor = "apple",
538542
)
539543
)))
540544
)]

src/socket.rs

+9-5
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
770770
socket._set_cloexec(true)?;
771771

772772
// On Apple platforms set `NOSIGPIPE`.
773-
#[cfg(target_vendor = "apple")]
773+
#[cfg(any(target_os = "ios", target_os = "macos"))]
774774
socket._set_nosigpipe(true)?;
775775

776776
Ok(socket)
@@ -1794,9 +1794,10 @@ impl Socket {
17941794
target_os = "freebsd",
17951795
target_os = "fuchsia",
17961796
target_os = "illumos",
1797+
target_os = "ios",
17971798
target_os = "linux",
1799+
target_os = "macos",
17981800
target_os = "netbsd",
1799-
target_vendor = "apple",
18001801
)
18011802
))]
18021803
#[cfg_attr(
@@ -1809,9 +1810,10 @@ impl Socket {
18091810
target_os = "freebsd",
18101811
target_os = "fuchsia",
18111812
target_os = "illumos",
1813+
target_os = "ios",
18121814
target_os = "linux",
1815+
target_os = "macos",
18131816
target_os = "netbsd",
1814-
target_vendor = "apple",
18151817
)
18161818
)))
18171819
)]
@@ -1835,9 +1837,10 @@ impl Socket {
18351837
target_os = "freebsd",
18361838
target_os = "fuchsia",
18371839
target_os = "illumos",
1840+
target_os = "ios",
18381841
target_os = "linux",
1842+
target_os = "macos",
18391843
target_os = "netbsd",
1840-
target_vendor = "apple",
18411844
)
18421845
))]
18431846
#[cfg_attr(
@@ -1850,9 +1853,10 @@ impl Socket {
18501853
target_os = "freebsd",
18511854
target_os = "fuchsia",
18521855
target_os = "illumos",
1856+
target_os = "ios",
18531857
target_os = "linux",
1858+
target_os = "macos",
18541859
target_os = "netbsd",
1855-
target_vendor = "apple",
18561860
)
18571861
)))
18581862
)]

src/sys/unix.rs

+47-28
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@ use std::marker::PhantomData;
1313
use std::mem::{self, size_of, MaybeUninit};
1414
use std::net::Shutdown;
1515
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")))]
1717
use std::num::NonZeroU32;
1818
#[cfg(all(
1919
feature = "all",
2020
any(
2121
target_os = "aix",
2222
target_os = "android",
2323
target_os = "freebsd",
24+
target_os = "ios",
2425
target_os = "linux",
25-
target_vendor = "apple",
26+
target_os = "macos",
2627
)
2728
))]
2829
use std::num::NonZeroUsize;
@@ -33,8 +34,9 @@ use std::os::unix::ffi::OsStrExt;
3334
target_os = "aix",
3435
target_os = "android",
3536
target_os = "freebsd",
37+
target_os = "ios",
3638
target_os = "linux",
37-
target_vendor = "apple",
39+
target_os = "macos",
3840
)
3941
))]
4042
use std::os::unix::io::RawFd;
@@ -46,7 +48,7 @@ use std::ptr;
4648
use std::time::{Duration, Instant};
4749
use std::{io, slice};
4850

49-
#[cfg(not(target_vendor = "apple"))]
51+
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
5052
use libc::ssize_t;
5153
use libc::{in6_addr, in_addr};
5254

@@ -117,9 +119,9 @@ pub(crate) use libc::IP_RECVTOS;
117119
target_os = "illumos",
118120
)))]
119121
pub(crate) use libc::IP_TOS;
120-
#[cfg(not(target_vendor = "apple"))]
122+
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
121123
pub(crate) use libc::SO_LINGER;
122-
#[cfg(target_vendor = "apple")]
124+
#[cfg(any(target_os = "ios", target_os = "macos"))]
123125
pub(crate) use libc::SO_LINGER_SEC as SO_LINGER;
124126
pub(crate) use libc::{
125127
ip_mreq as IpMreq, linger, IPPROTO_IP, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, IPV6_MULTICAST_IF,
@@ -145,22 +147,24 @@ pub(crate) use libc::{
145147
target_os = "freebsd",
146148
target_os = "haiku",
147149
target_os = "illumos",
150+
target_os = "ios",
151+
target_os = "macos",
148152
target_os = "netbsd",
153+
target_os = "nto",
149154
target_os = "openbsd",
150155
target_os = "solaris",
151-
target_os = "nto",
152-
target_vendor = "apple"
153156
)))]
154157
pub(crate) use libc::{IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP};
155158
#[cfg(any(
156159
target_os = "dragonfly",
157160
target_os = "freebsd",
158161
target_os = "haiku",
159162
target_os = "illumos",
163+
target_os = "ios",
164+
target_os = "macos",
160165
target_os = "netbsd",
161166
target_os = "openbsd",
162167
target_os = "solaris",
163-
target_vendor = "apple",
164168
))]
165169
pub(crate) use libc::{
166170
IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP, IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP,
@@ -173,23 +177,25 @@ pub(crate) use libc::{
173177
target_os = "freebsd",
174178
target_os = "fuchsia",
175179
target_os = "illumos",
180+
target_os = "ios",
176181
target_os = "linux",
182+
target_os = "macos",
177183
target_os = "netbsd",
178-
target_vendor = "apple",
179184
)
180185
))]
181186
pub(crate) use libc::{TCP_KEEPCNT, TCP_KEEPINTVL};
182187

183188
// See this type in the Windows file.
184189
pub(crate) type Bool = c_int;
185190

186-
#[cfg(any(target_vendor = "apple", target_os = "nto"))]
191+
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "nto"))]
187192
use libc::TCP_KEEPALIVE as KEEPALIVE_TIME;
188193
#[cfg(not(any(
189-
target_vendor = "apple",
190194
target_os = "haiku",
191-
target_os = "openbsd",
195+
target_os = "ios",
196+
target_os = "macos",
192197
target_os = "nto",
198+
target_os = "openbsd",
193199
)))]
194200
use libc::TCP_KEEPIDLE as KEEPALIVE_TIME;
195201

@@ -207,7 +213,7 @@ macro_rules! syscall {
207213
}
208214

209215
/// 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")))]
211217
const MAX_BUF_LEN: usize = ssize_t::MAX as usize;
212218

213219
// 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;
218224
// intentionally showing odd behavior by rejecting any read with a size larger
219225
// than or equal to INT_MAX. To handle both of these the read size is capped on
220226
// both platforms.
221-
#[cfg(target_vendor = "apple")]
227+
#[cfg(any(target_os = "ios", target_os = "macos"))]
222228
const MAX_BUF_LEN: usize = c_int::MAX as usize - 1;
223229

224230
// TCP_CA_NAME_MAX isn't defined in user space include files(not in libc)
@@ -251,11 +257,12 @@ type IovLen = usize;
251257
target_os = "fuchsia",
252258
target_os = "haiku",
253259
target_os = "illumos",
260+
target_os = "ios",
261+
target_os = "macos",
254262
target_os = "netbsd",
263+
target_os = "nto",
255264
target_os = "openbsd",
256265
target_os = "solaris",
257-
target_os = "nto",
258-
target_vendor = "apple",
259266
))]
260267
type IovLen = c_int;
261268

@@ -939,9 +946,10 @@ pub(crate) fn set_tcp_keepalive(fd: Socket, keepalive: &TcpKeepalive) -> io::Res
939946
target_os = "freebsd",
940947
target_os = "fuchsia",
941948
target_os = "illumos",
949+
target_os = "ios",
942950
target_os = "linux",
951+
target_os = "macos",
943952
target_os = "netbsd",
944-
target_vendor = "apple",
945953
))]
946954
{
947955
if let Some(interval) = keepalive.interval {
@@ -1177,13 +1185,16 @@ impl crate::Socket {
11771185
}
11781186

11791187
/// 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+
)]
11821193
pub fn set_nosigpipe(&self, nosigpipe: bool) -> io::Result<()> {
11831194
self._set_nosigpipe(nosigpipe)
11841195
}
11851196

1186-
#[cfg(target_vendor = "apple")]
1197+
#[cfg(any(target_os = "ios", target_os = "macos"))]
11871198
pub(crate) fn _set_nosigpipe(&self, nosigpipe: bool) -> io::Result<()> {
11881199
unsafe {
11891200
setsockopt(
@@ -1621,8 +1632,11 @@ impl crate::Socket {
16211632
///
16221633
/// One can use [`libc::if_nametoindex`] to convert an interface alias to an
16231634
/// 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+
)]
16261640
pub fn bind_device_by_index(&self, interface: Option<NonZeroU32>) -> io::Result<()> {
16271641
let index = interface.map_or(0, NonZeroU32::get);
16281642
unsafe { setsockopt(self.as_raw(), IPPROTO_IP, libc::IP_BOUND_IF, index) }
@@ -1633,8 +1647,11 @@ impl crate::Socket {
16331647
///
16341648
/// Returns `None` if the socket is not bound to any interface, otherwise
16351649
/// 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+
)]
16381655
pub fn device_index(&self) -> io::Result<Option<NonZeroU32>> {
16391656
let index =
16401657
unsafe { getsockopt::<libc::c_uint>(self.as_raw(), IPPROTO_IP, libc::IP_BOUND_IF)? };
@@ -1921,8 +1938,9 @@ impl crate::Socket {
19211938
target_os = "aix",
19221939
target_os = "android",
19231940
target_os = "freebsd",
1941+
target_os = "ios",
19241942
target_os = "linux",
1925-
target_vendor = "apple",
1943+
target_os = "macos",
19261944
)
19271945
))]
19281946
#[cfg_attr(
@@ -1933,8 +1951,9 @@ impl crate::Socket {
19331951
target_os = "aix",
19341952
target_os = "android",
19351953
target_os = "freebsd",
1954+
target_os = "ios",
19361955
target_os = "linux",
1937-
target_vendor = "apple",
1956+
target_os = "macos",
19381957
)
19391958
)))
19401959
)]
@@ -1950,7 +1969,7 @@ impl crate::Socket {
19501969
self._sendfile(file.as_raw_fd(), offset as _, length)
19511970
}
19521971

1953-
#[cfg(all(feature = "all", target_vendor = "apple"))]
1972+
#[cfg(all(feature = "all", any(target_os = "ios", target_os = "macos")))]
19541973
fn _sendfile(
19551974
&self,
19561975
file: RawFd,

0 commit comments

Comments
 (0)