about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoe Ellis <joe.ellis@arm.com>2020-09-08 16:08:21 +0100
committerJoe Ellis <joe.ellis@arm.com>2020-09-14 10:31:56 +0100
commit72eef6168f2a5427ccd398a60db7ee56e419b393 (patch)
tree2130098a491d2910874c09b69b0e469bedd33029
parentfa697dfa8179b7f5c5a1207935828e3a938f2fea (diff)
downloadrust-72eef6168f2a5427ccd398a60db7ee56e419b393.tar.gz
rust-72eef6168f2a5427ccd398a60db7ee56e419b393.zip
Conditionally compile peer credentials feature for supported platforms
-rw-r--r--library/std/src/sys/unix/ext/net.rs9
-rw-r--r--library/std/src/sys/unix/ext/ucred/tests.rs9
2 files changed, 18 insertions, 0 deletions
diff --git a/library/std/src/sys/unix/ext/net.rs b/library/std/src/sys/unix/ext/net.rs
index ac8d6cf53ff..f664a072c65 100644
--- a/library/std/src/sys/unix/ext/net.rs
+++ b/library/std/src/sys/unix/ext/net.rs
@@ -443,6 +443,15 @@ impl UnixStream {
     /// }
     /// ```
     #[unstable(feature = "peer_credentials_unix_socket", issue = "42839", reason = "unstable")]
+    #[cfg(any(
+        target_os = "android",
+        target_os = "linux",
+        target_os = "dragonfly",
+        target_os = "freebsd",
+        target_os = "ios",
+        target_os = "macos",
+        target_os = "openbsd"
+    ))]
     pub fn peer_cred(&self) -> io::Result<UCred> {
         ucred::peer_cred(self)
     }
diff --git a/library/std/src/sys/unix/ext/ucred/tests.rs b/library/std/src/sys/unix/ext/ucred/tests.rs
index efe99467210..451b534b266 100644
--- a/library/std/src/sys/unix/ext/ucred/tests.rs
+++ b/library/std/src/sys/unix/ext/ucred/tests.rs
@@ -2,6 +2,15 @@ use crate::os::unix::net::UnixStream;
 use libc::{getegid, geteuid};
 
 #[test]
+#[cfg(any(
+    target_os = "android",
+    target_os = "linux",
+    target_os = "dragonfly",
+    target_os = "freebsd",
+    target_os = "ios",
+    target_os = "macos",
+    target_os = "openbsd"
+))]
 fn test_socket_pair() {
     // Create two connected sockets and get their peer credentials. They should be equal.
     let (sock_a, sock_b) = UnixStream::pair().unwrap();