Use target_vendor = "apple" instead of target_os = "..."

This commit is contained in:
Mads Marquart
2024-04-28 18:22:37 +02:00
parent cb49406457
commit d9c0eb8084
18 changed files with 74 additions and 336 deletions

View File

@@ -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::*;

View File

@@ -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)

View File

@@ -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;

View File

@@ -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();