Auto merge of #124491 - madsmtm:target_vendor-apple, r=workingjubilee
Use `target_vendor = "apple"` instead of `target_os = "..."` Use `target_vendor = "apple"` instead of `all(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos")`. The apple targets are quite close to being identical, with iOS, tvOS, watchOS and visionOS being even closer, so using `target_vendor` when possible makes it clearer when something is actually OS-specific, or just Apple-specific. Note that `target_vendor` will [be deprecated in the future](https://github.com/rust-lang/rust/issues/100343), but not before an alternative (like `target_family = "apple"`) is available. While doing this, I found various inconsistencies and small mistakes in the standard library, see the commits for details. Will follow-up with an extra PR for a similar issue that need a bit more discussion. EDIT: https://github.com/rust-lang/rust/pull/124494 Since you've talked about using `target_vendor = "apple"` in the past: r? workingjubilee CC `@simlay,` `@thomcc` `@rustbot` label O-macos O-ios O-tvos O-watchos O-visionos
This commit is contained in:
commit
2e88e9e7d0
21 changed files with 90 additions and 372 deletions
|
@ -213,7 +213,7 @@ impl fmt::Debug for c_void {
|
|||
not(target_arch = "s390x"),
|
||||
not(target_arch = "x86_64")
|
||||
),
|
||||
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
|
||||
all(target_arch = "aarch64", target_vendor = "apple"),
|
||||
target_family = "wasm",
|
||||
target_os = "uefi",
|
||||
windows,
|
||||
|
@ -241,7 +241,7 @@ pub struct VaListImpl<'f> {
|
|||
not(target_arch = "s390x"),
|
||||
not(target_arch = "x86_64")
|
||||
),
|
||||
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
|
||||
all(target_arch = "aarch64", target_vendor = "apple"),
|
||||
target_family = "wasm",
|
||||
target_os = "uefi",
|
||||
windows,
|
||||
|
@ -265,7 +265,7 @@ impl<'f> fmt::Debug for VaListImpl<'f> {
|
|||
/// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0055b/IHI0055B_aapcs64.pdf
|
||||
#[cfg(all(
|
||||
target_arch = "aarch64",
|
||||
not(any(target_os = "macos", target_os = "ios", target_os = "tvos")),
|
||||
not(target_vendor = "apple"),
|
||||
not(target_os = "uefi"),
|
||||
not(windows),
|
||||
))]
|
||||
|
@ -362,10 +362,7 @@ pub struct VaList<'a, 'f: 'a> {
|
|||
not(target_arch = "s390x"),
|
||||
not(target_arch = "x86_64")
|
||||
),
|
||||
all(
|
||||
target_arch = "aarch64",
|
||||
any(target_os = "macos", target_os = "ios", target_os = "tvos")
|
||||
),
|
||||
all(target_arch = "aarch64", target_vendor = "apple"),
|
||||
target_family = "wasm",
|
||||
target_os = "uefi",
|
||||
windows,
|
||||
|
@ -379,10 +376,7 @@ pub struct VaList<'a, 'f: 'a> {
|
|||
target_arch = "s390x",
|
||||
target_arch = "x86_64"
|
||||
),
|
||||
any(
|
||||
not(target_arch = "aarch64"),
|
||||
not(any(target_os = "macos", target_os = "ios", target_os = "tvos"))
|
||||
),
|
||||
any(not(target_arch = "aarch64"), not(target_vendor = "apple")),
|
||||
not(target_family = "wasm"),
|
||||
not(target_os = "uefi"),
|
||||
not(windows),
|
||||
|
@ -399,7 +393,7 @@ pub struct VaList<'a, 'f: 'a> {
|
|||
not(target_arch = "s390x"),
|
||||
not(target_arch = "x86_64")
|
||||
),
|
||||
all(target_arch = "aarch64", any(target_os = "macos", target_os = "ios", target_os = "tvos")),
|
||||
all(target_arch = "aarch64", target_vendor = "apple"),
|
||||
target_family = "wasm",
|
||||
target_os = "uefi",
|
||||
windows,
|
||||
|
@ -425,10 +419,7 @@ impl<'f> VaListImpl<'f> {
|
|||
target_arch = "s390x",
|
||||
target_arch = "x86_64"
|
||||
),
|
||||
any(
|
||||
not(target_arch = "aarch64"),
|
||||
not(any(target_os = "macos", target_os = "ios", target_os = "tvos"))
|
||||
),
|
||||
any(not(target_arch = "aarch64"), not(target_vendor = "apple")),
|
||||
not(target_family = "wasm"),
|
||||
not(target_os = "uefi"),
|
||||
not(windows),
|
||||
|
|
|
@ -1657,23 +1657,9 @@ fn test_file_times() {
|
|||
let accessed = SystemTime::UNIX_EPOCH + Duration::from_secs(12345);
|
||||
let modified = SystemTime::UNIX_EPOCH + Duration::from_secs(54321);
|
||||
times = times.set_accessed(accessed).set_modified(modified);
|
||||
#[cfg(any(
|
||||
windows,
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
#[cfg(any(windows, target_vendor = "apple"))]
|
||||
let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123);
|
||||
#[cfg(any(
|
||||
windows,
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
#[cfg(any(windows, target_vendor = "apple"))]
|
||||
{
|
||||
times = times.set_created(created);
|
||||
}
|
||||
|
@ -1698,27 +1684,14 @@ fn test_file_times() {
|
|||
let metadata = file.metadata().unwrap();
|
||||
assert_eq!(metadata.accessed().unwrap(), accessed);
|
||||
assert_eq!(metadata.modified().unwrap(), modified);
|
||||
#[cfg(any(
|
||||
windows,
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
#[cfg(any(windows, target_vendor = "apple"))]
|
||||
{
|
||||
assert_eq!(metadata.created().unwrap(), created);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
fn test_file_times_pre_epoch_with_nanos() {
|
||||
#[cfg(target_os = "ios")]
|
||||
use crate::os::ios::fs::FileTimesExt;
|
||||
|
|
|
@ -17,14 +17,10 @@ mod tests;
|
|||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
mod ucred;
|
||||
|
||||
|
@ -44,14 +40,10 @@ pub use self::stream::*;
|
|||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
#[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
|
||||
pub use self::ucred::*;
|
||||
|
|
|
@ -3,14 +3,10 @@
|
|||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto"
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
use super::{peer_cred, UCred};
|
||||
#[cfg(any(doc, target_os = "android", target_os = "linux"))]
|
||||
|
@ -231,14 +227,10 @@ impl UnixStream {
|
|||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto"
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn peer_cred(&self) -> io::Result<UCred> {
|
||||
peer_cred(self)
|
||||
|
|
|
@ -35,14 +35,8 @@ pub(super) use self::impl_linux::peer_cred;
|
|||
))]
|
||||
pub(super) use self::impl_bsd::peer_cred;
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
pub(super) use self::impl_mac::peer_cred;
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub(super) use self::impl_apple::peer_cred;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
mod impl_linux {
|
||||
|
@ -103,14 +97,8 @@ mod impl_bsd {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
mod impl_mac {
|
||||
#[cfg(target_vendor = "apple")]
|
||||
mod impl_apple {
|
||||
use super::UCred;
|
||||
use crate::os::unix::io::AsRawFd;
|
||||
use crate::os::unix::net::UnixStream;
|
||||
|
|
|
@ -7,12 +7,8 @@ use libc::{getegid, geteuid, getpid};
|
|||
target_os = "linux",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "openbsd"
|
||||
target_os = "openbsd",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
fn test_socket_pair() {
|
||||
// Create two connected sockets and get their peer credentials. They should be equal.
|
||||
|
@ -28,14 +24,7 @@ fn test_socket_pair() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
#[cfg(any(target_os = "linux", target_vendor = "apple"))]
|
||||
fn test_socket_pair_pids(arg: Type) -> RetType {
|
||||
// Create two connected sockets and get their peer credentials.
|
||||
let (sock_a, sock_b) = UnixStream::pair().unwrap();
|
||||
|
|
|
@ -168,13 +168,7 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
mod imp {
|
||||
use super::Args;
|
||||
use crate::ffi::CStr;
|
||||
|
@ -215,12 +209,7 @@ mod imp {
|
|||
// for i in (0..[args count])
|
||||
// res.push([args objectAtIndex:i])
|
||||
// res
|
||||
#[cfg(any(
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
pub fn args() -> Args {
|
||||
use crate::ffi::{c_char, c_void, OsString};
|
||||
use crate::mem;
|
||||
|
|
|
@ -20,14 +20,7 @@ use crate::sys::time::SystemTime;
|
|||
use crate::sys::{cvt, cvt_r};
|
||||
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
|
||||
|
||||
#[cfg(any(
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[cfg(any(all(target_os = "linux", target_env = "gnu"), target_vendor = "apple"))]
|
||||
use crate::sys::weak::syscall;
|
||||
#[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))]
|
||||
use crate::sys::weak::weak;
|
||||
|
@ -35,13 +28,9 @@ use crate::sys::weak::weak;
|
|||
use libc::{c_int, mode_t};
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "solaris",
|
||||
all(target_os = "linux", target_env = "gnu")
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
use libc::c_char;
|
||||
#[cfg(any(
|
||||
|
@ -375,13 +364,7 @@ pub struct FilePermissions {
|
|||
pub struct FileTimes {
|
||||
accessed: Option<SystemTime>,
|
||||
modified: Option<SystemTime>,
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
created: Option<SystemTime>,
|
||||
}
|
||||
|
||||
|
@ -554,15 +537,7 @@ impl FileAttr {
|
|||
SystemTime::new(self.stat.st_atim.tv_sec as i64, self.stat.st_atim.tv_nsec as i64)
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[cfg(any(target_os = "freebsd", target_os = "openbsd", target_vendor = "apple"))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
SystemTime::new(self.stat.st_birthtime as i64, self.stat.st_birthtime_nsec as i64)
|
||||
}
|
||||
|
@ -570,12 +545,8 @@ impl FileAttr {
|
|||
#[cfg(not(any(
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "vita",
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
cfg_has_statx! {
|
||||
|
@ -655,13 +626,7 @@ impl FileTimes {
|
|||
self.modified = Some(t);
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub fn set_created(&mut self, t: SystemTime) {
|
||||
self.created = Some(t);
|
||||
}
|
||||
|
@ -996,11 +961,6 @@ impl DirEntry {
|
|||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "linux",
|
||||
target_os = "emscripten",
|
||||
target_os = "android",
|
||||
|
@ -1017,6 +977,7 @@ impl DirEntry {
|
|||
target_os = "aix",
|
||||
target_os = "nto",
|
||||
target_os = "hurd",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub fn ino(&self) -> u64 {
|
||||
self.entry.d_ino as u64
|
||||
|
@ -1033,15 +994,11 @@ impl DirEntry {
|
|||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"
|
||||
target_os = "dragonfly",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
fn name_bytes(&self) -> &[u8] {
|
||||
use crate::slice;
|
||||
|
@ -1053,15 +1010,11 @@ impl DirEntry {
|
|||
}
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
target_os = "dragonfly"
|
||||
target_os = "dragonfly",
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
fn name_bytes(&self) -> &[u8] {
|
||||
self.name_cstr().to_bytes()
|
||||
|
@ -1239,23 +1192,11 @@ impl File {
|
|||
cvt_r(|| unsafe { os_fsync(self.as_raw_fd()) })?;
|
||||
return Ok(());
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
)))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fsync(fd)
|
||||
}
|
||||
|
@ -1265,13 +1206,7 @@ impl File {
|
|||
cvt_r(|| unsafe { os_datasync(self.as_raw_fd()) })?;
|
||||
return Ok(());
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
}
|
||||
|
@ -1290,16 +1225,12 @@ impl File {
|
|||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "nto",
|
||||
target_os = "hurd",
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
libc::fsync(fd)
|
||||
|
@ -1408,7 +1339,7 @@ impl File {
|
|||
io::ErrorKind::Unsupported,
|
||||
"setting file times not supported",
|
||||
))
|
||||
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] {
|
||||
} else if #[cfg(target_vendor = "apple")] {
|
||||
let mut buf = [mem::MaybeUninit::<libc::timespec>::uninit(); 3];
|
||||
let mut num_times = 0;
|
||||
let mut attrlist: libc::attrlist = unsafe { mem::zeroed() };
|
||||
|
@ -1940,15 +1871,7 @@ fn open_to_and_set_permissions(
|
|||
Ok((writer, writer_metadata))
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
)))]
|
||||
#[cfg(not(any(target_os = "linux", target_os = "android", target_vendor = "apple")))]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
let (mut reader, reader_metadata) = open_from(from)?;
|
||||
let (mut writer, _) = open_to_and_set_permissions(to, reader_metadata)?;
|
||||
|
@ -1974,13 +1897,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
use crate::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
|
|
|
@ -78,16 +78,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
|
|||
target_os = "emscripten",
|
||||
target_os = "fuchsia",
|
||||
target_os = "vxworks",
|
||||
// The poll on Darwin doesn't set POLLNVAL for closed fds.
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "redox",
|
||||
target_os = "l4re",
|
||||
target_os = "horizon",
|
||||
target_os = "vita",
|
||||
// The poll on Darwin doesn't set POLLNVAL for closed fds.
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
'poll: {
|
||||
use crate::sys::os::errno;
|
||||
|
@ -406,7 +402,7 @@ cfg_if::cfg_if! {
|
|||
} else if #[cfg(target_os = "macos")] {
|
||||
#[link(name = "System")]
|
||||
extern "C" {}
|
||||
} else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] {
|
||||
} else if #[cfg(all(target_vendor = "apple", not(target_os = "macos")))] {
|
||||
#[link(name = "System")]
|
||||
#[link(name = "objc")]
|
||||
#[link(name = "Foundation", kind = "framework")]
|
||||
|
|
|
@ -63,17 +63,7 @@ extern "C" {
|
|||
)]
|
||||
#[cfg_attr(any(target_os = "solaris", target_os = "illumos"), link_name = "___errno")]
|
||||
#[cfg_attr(target_os = "nto", link_name = "__get_errno_ptr")]
|
||||
#[cfg_attr(
|
||||
any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "freebsd",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
),
|
||||
link_name = "__error"
|
||||
)]
|
||||
#[cfg_attr(any(target_os = "freebsd", target_vendor = "apple"), link_name = "__error")]
|
||||
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
|
||||
#[cfg_attr(target_os = "aix", link_name = "_Errno")]
|
||||
fn errno_location() -> *mut c_int;
|
||||
|
@ -431,13 +421,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||
Ok(PathBuf::from(OsString::from_vec(e)))
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub fn current_exe() -> io::Result<PathBuf> {
|
||||
unsafe {
|
||||
let mut sz: u32 = 0;
|
||||
|
@ -703,32 +687,26 @@ pub fn home_dir() -> Option<PathBuf> {
|
|||
|
||||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
target_os = "vita",
|
||||
all(target_vendor = "apple", not(target_os = "macos")),
|
||||
))]
|
||||
unsafe fn fallback() -> Option<OsString> {
|
||||
None
|
||||
}
|
||||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
target_os = "vita",
|
||||
all(target_vendor = "apple", not(target_os = "macos")),
|
||||
)))]
|
||||
unsafe fn fallback() -> Option<OsString> {
|
||||
let amt = match libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX) {
|
||||
|
|
|
@ -420,13 +420,11 @@ impl Command {
|
|||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "freebsd",
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
all(target_os = "linux", target_env = "musl"),
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
fn posix_spawn(
|
||||
&mut self,
|
||||
|
@ -439,14 +437,11 @@ impl Command {
|
|||
// Only support platforms for which posix_spawn() can return ENOENT
|
||||
// directly.
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
// FIXME: `target_os = "ios"`?
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "freebsd",
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
all(target_os = "linux", target_env = "musl"),
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
fn posix_spawn(
|
||||
&mut self,
|
||||
|
@ -530,7 +525,7 @@ impl Command {
|
|||
}
|
||||
let addchdir = match self.get_cwd() {
|
||||
Some(cwd) => {
|
||||
if cfg!(any(target_os = "macos", target_os = "tvos", target_os = "watchos")) {
|
||||
if cfg!(target_vendor = "apple") {
|
||||
// There is a bug in macOS where a relative executable
|
||||
// path like "../myprogram" will cause `posix_spawn` to
|
||||
// successfully launch the program, but erroneously return
|
||||
|
@ -1040,24 +1035,20 @@ fn signal_string(signal: i32) -> &'static str {
|
|||
#[cfg(any(target_os = "linux", target_os = "nto"))]
|
||||
libc::SIGPWR => " (SIGPWR)",
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "dragonfly",
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
libc::SIGEMT => " (SIGEMT)",
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "dragonfly"
|
||||
target_os = "dragonfly",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
libc::SIGINFO => " (SIGINFO)",
|
||||
#[cfg(target_os = "hurd")]
|
||||
|
|
|
@ -12,11 +12,6 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
|||
|
||||
#[cfg(all(
|
||||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "tvos"),
|
||||
not(target_os = "watchos"),
|
||||
not(target_os = "visionos"),
|
||||
not(target_os = "openbsd"),
|
||||
not(target_os = "netbsd"),
|
||||
not(target_os = "fuchsia"),
|
||||
|
@ -24,6 +19,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
|||
not(target_os = "vxworks"),
|
||||
not(target_os = "emscripten"),
|
||||
not(target_os = "vita"),
|
||||
not(target_vendor = "apple"),
|
||||
))]
|
||||
mod imp {
|
||||
use crate::fs::File;
|
||||
|
|
|
@ -150,13 +150,7 @@ impl Thread {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub fn set_name(name: &CStr) {
|
||||
unsafe {
|
||||
let name = truncate_cstr::<{ libc::MAXTHREADNAMESIZE }>(name);
|
||||
|
@ -301,14 +295,10 @@ impl Drop for Thread {
|
|||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "nto",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
fn truncate_cstr<const MAX_WITH_NUL: usize>(cstr: &CStr) -> [libc::c_char; MAX_WITH_NUL] {
|
||||
let mut result = [0; MAX_WITH_NUL];
|
||||
|
@ -325,11 +315,9 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
|
|||
target_os = "emscripten",
|
||||
target_os = "fuchsia",
|
||||
target_os = "hurd",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "aix",
|
||||
target_vendor = "apple",
|
||||
))] {
|
||||
#[allow(unused_assignments)]
|
||||
#[allow(unused_mut)]
|
||||
|
|
|
@ -76,13 +76,7 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
|
|||
// workaround below is to register, via _tlv_atexit, a custom DTOR list once per
|
||||
// thread. thread_local dtors are pushed to the DTOR list without calling
|
||||
// _tlv_atexit.
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
|
||||
use crate::cell::{Cell, RefCell};
|
||||
use crate::ptr;
|
||||
|
|
|
@ -11,16 +11,7 @@
|
|||
)))]
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(
|
||||
any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
),
|
||||
not(miri),
|
||||
))] {
|
||||
if #[cfg(all(target_vendor = "apple", not(miri)))] {
|
||||
mod darwin;
|
||||
pub use darwin::Parker;
|
||||
} else if #[cfg(target_os = "netbsd")] {
|
||||
|
|
|
@ -43,15 +43,7 @@ unsafe fn wait_timeout(
|
|||
) {
|
||||
// Use the system clock on systems that do not support pthread_condattr_setclock.
|
||||
// This unfortunately results in problems when the system time changes.
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
))]
|
||||
#[cfg(any(target_os = "espidf", target_os = "horizon", target_vendor = "apple"))]
|
||||
let (now, dur) = {
|
||||
use crate::cmp::min;
|
||||
use crate::sys::time::SystemTime;
|
||||
|
@ -72,15 +64,7 @@ unsafe fn wait_timeout(
|
|||
(now, dur)
|
||||
};
|
||||
// Use the monotonic clock on other systems.
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
)))]
|
||||
#[cfg(not(any(target_os = "espidf", target_os = "horizon", target_vendor = "apple")))]
|
||||
let (now, dur) = {
|
||||
use crate::sys::time::Timespec;
|
||||
|
||||
|
@ -122,15 +106,11 @@ impl Parker {
|
|||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox",
|
||||
target_os = "vita",
|
||||
target_vendor = "apple",
|
||||
))] {
|
||||
addr_of_mut!((*parker).cvar).write(UnsafeCell::new(libc::PTHREAD_COND_INITIALIZER));
|
||||
} else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] {
|
||||
|
|
|
@ -86,13 +86,7 @@ impl Timespec {
|
|||
// Please note that Apple OS nonetheless accepts the standard unix format when
|
||||
// setting file times, which makes this compensation round-trippable and generally
|
||||
// transparent.
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
let (tv_sec, tv_nsec) =
|
||||
if (tv_sec <= 0 && tv_sec > i64::MIN) && (tv_nsec < 0 && tv_nsec > -1_000_000_000) {
|
||||
(tv_sec - 1, tv_nsec + 1_000_000_000)
|
||||
|
@ -275,21 +269,9 @@ impl Instant {
|
|||
//
|
||||
// Instant on macos was historically implemented using mach_absolute_time;
|
||||
// we preserve this value domain out of an abundance of caution.
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
const clock_id: libc::clockid_t = libc::CLOCK_UPTIME_RAW;
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
)))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
const clock_id: libc::clockid_t = libc::CLOCK_MONOTONIC;
|
||||
Instant { t: Timespec::now(clock_id) }
|
||||
}
|
||||
|
|
|
@ -30,14 +30,10 @@ impl LazyInit for AllocatedCondvar {
|
|||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox"
|
||||
target_os = "redox",
|
||||
target_vendor = "apple",
|
||||
))] {
|
||||
// `pthread_condattr_setclock` is unfortunately not supported on these platforms.
|
||||
} else if #[cfg(any(target_os = "espidf", target_os = "horizon"))] {
|
||||
|
@ -124,14 +120,10 @@ impl Condvar {
|
|||
// default system clock). This approach avoids all problems that result
|
||||
// from changes made to the system time.
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
target_os = "horizon",
|
||||
target_vendor = "apple",
|
||||
)))]
|
||||
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
|
||||
use crate::sys::time::Timespec;
|
||||
|
@ -160,14 +152,10 @@ impl Condvar {
|
|||
// https://github.com/llvm-mirror/libcxx/blob/release_35/src/condition_variable.cpp#L46
|
||||
// https://github.com/llvm-mirror/libcxx/blob/release_35/include/__mutex_base#L367
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
target_os = "horizon",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
|
||||
use crate::sys::time::SystemTime;
|
||||
|
|
|
@ -17,10 +17,17 @@ use crate::ffi::{c_int, c_void};
|
|||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "dragonfly", target_os = "freebsd",
|
||||
target_os = "ios", target_os = "tvos", target_os = "macos", target_os = "watchos", target_os = "visionos",
|
||||
target_os = "openbsd", target_os = "netbsd", target_os = "illumos",
|
||||
target_os = "solaris", target_os = "haiku", target_os = "l4re", target_os = "nto"))] {
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "illumos",
|
||||
target_os = "solaris",
|
||||
target_os = "haiku",
|
||||
target_os = "l4re",
|
||||
target_os = "nto",
|
||||
target_vendor = "apple",
|
||||
))] {
|
||||
use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
|
||||
use crate::sys::net::netc::IPV6_LEAVE_GROUP as IPV6_DROP_MEMBERSHIP;
|
||||
} else {
|
||||
|
|
|
@ -40,11 +40,7 @@ fn test_named_thread() {
|
|||
#[cfg(any(
|
||||
// Note: musl didn't add pthread_getname_np until 1.2.3
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_vendor = "apple",
|
||||
))]
|
||||
#[test]
|
||||
fn test_named_thread_truncation() {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/// on the number of cores available.
|
||||
///
|
||||
/// This fixes issue #7772.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "visionos"))]
|
||||
#[cfg(target_vendor = "apple")]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub unsafe fn raise_fd_limit() {
|
||||
use std::cmp;
|
||||
|
@ -50,5 +50,5 @@ pub unsafe fn raise_fd_limit() {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(target_vendor = "apple"))]
|
||||
pub unsafe fn raise_fd_limit() {}
|
||||
|
|
Loading…
Add table
Reference in a new issue