about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorLinkTed <LinkTed@users.noreply.github.com>2020-08-28 18:41:48 +0200
committerLinkTed <LinkTed@users.noreply.github.com>2020-10-10 15:19:12 +0200
commit53791b3ff4322aec2a82a84952be91d1be4058b5 (patch)
tree221c4e534ef0c55a8e1b45ae98001eef58c5b4cf /library/std/src
parent07ed6afc6de728c6ea8d021156af318172b1dbbc (diff)
downloadrust-53791b3ff4322aec2a82a84952be91d1be4058b5.tar.gz
rust-53791b3ff4322aec2a82a84952be91d1be4058b5.zip
Move conditional compilation to the upper module and sort the target OS list alphabetically
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/unix/ext/net/ancillary.rs260
-rw-r--r--library/std/src/sys/unix/ext/net/datagram.rs48
-rw-r--r--library/std/src/sys/unix/ext/net/mod.rs32
-rw-r--r--library/std/src/sys/unix/ext/net/stream.rs48
4 files changed, 199 insertions, 189 deletions
diff --git a/library/std/src/sys/unix/ext/net/ancillary.rs b/library/std/src/sys/unix/ext/net/ancillary.rs
index 84a73ef8afd..1da3370b07d 100644
--- a/library/std/src/sys/unix/ext/net/ancillary.rs
+++ b/library/std/src/sys/unix/ext/net/ancillary.rs
@@ -158,10 +158,36 @@ impl<'a, T> Iterator for AncillaryDataIter<'a, T> {
     }
 }
 
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_env = "uclibc",
+))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 #[derive(Clone)]
 pub struct UCred(libc::ucred);
 
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_env = "uclibc",
+))]
 impl UCred {
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn new() -> UCred {
@@ -199,41 +225,9 @@ impl UCred {
     }
 }
 
-#[cfg(any(
-    target_os = "haiku",
-    target_os = "solaris",
-    target_os = "illumos",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "openbsd",
-    target_os = "netbsd",
-    target_os = "linux",
-    target_os = "android",
-    target_os = "emscripten",
-    target_os = "fuchsia",
-    target_env = "uclibc",
-))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 pub struct ScmRights<'a>(AncillaryDataIter<'a, RawFd>);
 
-#[cfg(any(
-    target_os = "haiku",
-    target_os = "solaris",
-    target_os = "illumos",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "openbsd",
-    target_os = "netbsd",
-    target_os = "linux",
-    target_os = "android",
-    target_os = "emscripten",
-    target_os = "fuchsia",
-    target_env = "uclibc",
-))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 impl<'a> Iterator for ScmRights<'a> {
     type Item = RawFd;
@@ -244,32 +238,32 @@ impl<'a> Iterator for ScmRights<'a> {
 }
 
 #[cfg(any(
-    target_os = "netbsd",
-    target_os = "openbsd",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "linux",
     target_os = "android",
+    target_os = "dragonfly",
     target_os = "emscripten",
+    target_os = "freebsd",
     target_os = "fuchsia",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
     target_env = "uclibc",
 ))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 pub struct ScmCredentials<'a>(AncillaryDataIter<'a, libc::ucred>);
 
 #[cfg(any(
-    target_os = "netbsd",
-    target_os = "openbsd",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "linux",
     target_os = "android",
+    target_os = "dragonfly",
     target_os = "emscripten",
+    target_os = "freebsd",
     target_os = "fuchsia",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
     target_env = "uclibc",
 ))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
@@ -288,58 +282,26 @@ pub enum AncillaryError {
     Unknown { cmsg_level: i32, cmsg_type: i32 },
 }
 
-#[cfg(any(
-    target_os = "haiku",
-    target_os = "solaris",
-    target_os = "illumos",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "openbsd",
-    target_os = "netbsd",
-    target_os = "linux",
-    target_os = "android",
-    target_os = "emscripten",
-    target_os = "fuchsia",
-    target_env = "uclibc",
-))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 pub enum AncillaryData<'a> {
     ScmRights(ScmRights<'a>),
     #[cfg(any(
-        target_os = "netbsd",
-        target_os = "openbsd",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "linux",
         target_os = "android",
+        target_os = "dragonfly",
         target_os = "emscripten",
+        target_os = "freebsd",
         target_os = "fuchsia",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
         target_env = "uclibc",
     ))]
     ScmCredentials(ScmCredentials<'a>),
 }
 
 impl<'a> AncillaryData<'a> {
-    #[cfg(any(
-        target_os = "haiku",
-        target_os = "solaris",
-        target_os = "illumos",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "openbsd",
-        target_os = "netbsd",
-        target_os = "linux",
-        target_os = "android",
-        target_os = "emscripten",
-        target_os = "fuchsia",
-        target_env = "uclibc",
-    ))]
     fn as_rights(data: &'a [u8]) -> Self {
         let ancillary_data_iter = AncillaryDataIter::new(data);
         let scm_rights = ScmRights(ancillary_data_iter);
@@ -347,16 +309,16 @@ impl<'a> AncillaryData<'a> {
     }
 
     #[cfg(any(
-        target_os = "netbsd",
-        target_os = "openbsd",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "linux",
         target_os = "android",
+        target_os = "dragonfly",
         target_os = "emscripten",
+        target_os = "freebsd",
         target_os = "fuchsia",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
         target_env = "uclibc",
     ))]
     fn as_credentials(data: &'a [u8]) -> Self {
@@ -365,22 +327,6 @@ impl<'a> AncillaryData<'a> {
         AncillaryData::ScmCredentials(scm_credentials)
     }
 
-    #[cfg(any(
-        target_os = "haiku",
-        target_os = "solaris",
-        target_os = "illumos",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "openbsd",
-        target_os = "netbsd",
-        target_os = "linux",
-        target_os = "android",
-        target_os = "emscripten",
-        target_os = "fuchsia",
-        target_env = "uclibc",
-    ))]
     fn try_from_cmsghdr(cmsg: &'a libc::cmsghdr) -> Result<Self, AncillaryError> {
         unsafe {
             let cmsg_len_zero = libc::CMSG_LEN(0) as usize;
@@ -392,20 +338,20 @@ impl<'a> AncillaryData<'a> {
                 libc::SOL_SOCKET => match (*cmsg).cmsg_type {
                     libc::SCM_RIGHTS => Ok(AncillaryData::as_rights(data)),
                     #[cfg(any(
-                        target_os = "linux",
                         target_os = "android",
                         target_os = "emscripten",
                         target_os = "fuchsia",
+                        target_os = "linux",
                         target_env = "uclibc",
                     ))]
                     libc::SCM_CREDENTIALS => Ok(AncillaryData::as_credentials(data)),
                     #[cfg(any(
-                        target_os = "netbsd",
-                        target_os = "openbsd",
-                        target_os = "freebsd",
                         target_os = "dragonfly",
-                        target_os = "macos",
+                        target_os = "freebsd",
                         target_os = "ios",
+                        target_os = "macos",
+                        target_os = "netbsd",
+                        target_os = "openbsd",
                     ))]
                     libc::SCM_CREDS => Ok(AncillaryData::as_credentials(data)),
                     cmsg_type => {
@@ -420,44 +366,12 @@ impl<'a> AncillaryData<'a> {
     }
 }
 
-#[cfg(any(
-    target_os = "haiku",
-    target_os = "solaris",
-    target_os = "illumos",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "openbsd",
-    target_os = "netbsd",
-    target_os = "linux",
-    target_os = "android",
-    target_os = "emscripten",
-    target_os = "fuchsia",
-    target_env = "uclibc",
-))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 pub struct Messages<'a> {
     buffer: &'a [u8],
     current: Option<&'a libc::cmsghdr>,
 }
 
-#[cfg(any(
-    target_os = "haiku",
-    target_os = "solaris",
-    target_os = "illumos",
-    target_os = "macos",
-    target_os = "ios",
-    target_os = "freebsd",
-    target_os = "dragonfly",
-    target_os = "openbsd",
-    target_os = "netbsd",
-    target_os = "linux",
-    target_os = "android",
-    target_os = "emscripten",
-    target_os = "fuchsia",
-    target_env = "uclibc",
-))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 impl<'a> Iterator for Messages<'a> {
     type Item = Result<AncillaryData<'a>, AncillaryError>;
@@ -554,22 +468,6 @@ impl<'a> SocketAncillary<'a> {
         self.length
     }
 
-    #[cfg(any(
-        target_os = "haiku",
-        target_os = "solaris",
-        target_os = "illumos",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "openbsd",
-        target_os = "netbsd",
-        target_os = "linux",
-        target_os = "android",
-        target_os = "emscripten",
-        target_os = "fuchsia",
-        target_env = "uclibc",
-    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn messages(&self) -> Messages<'_> {
         Messages { buffer: &self.buffer[..self.length], current: None }
@@ -631,22 +529,6 @@ impl<'a> SocketAncillary<'a> {
     ///     Ok(())
     /// }
     /// ```
-    #[cfg(any(
-        target_os = "haiku",
-        target_os = "solaris",
-        target_os = "illumos",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "openbsd",
-        target_os = "netbsd",
-        target_os = "linux",
-        target_os = "android",
-        target_os = "emscripten",
-        target_os = "fuchsia",
-        target_env = "uclibc",
-    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn add_fds(&mut self, fds: &[RawFd]) -> bool {
         self.truncated = false;
@@ -667,16 +549,16 @@ impl<'a> SocketAncillary<'a> {
     /// and type `SCM_CREDENTIALS`.
     ///
     #[cfg(any(
-        target_os = "netbsd",
-        target_os = "openbsd",
-        target_os = "freebsd",
-        target_os = "dragonfly",
-        target_os = "macos",
-        target_os = "ios",
-        target_os = "linux",
         target_os = "android",
+        target_os = "dragonfly",
         target_os = "emscripten",
+        target_os = "freebsd",
         target_os = "fuchsia",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
         target_env = "uclibc",
     ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
@@ -688,20 +570,20 @@ impl<'a> SocketAncillary<'a> {
             creds,
             libc::SOL_SOCKET,
             #[cfg(any(
-                target_os = "linux",
                 target_os = "android",
                 target_os = "emscripten",
                 target_os = "fuchsia",
+                target_os = "linux",
                 target_env = "uclibc",
             ))]
             libc::SCM_CREDENTIALS,
             #[cfg(any(
-                target_os = "netbsd",
-                target_os = "openbsd",
-                target_os = "freebsd",
                 target_os = "dragonfly",
-                target_os = "macos",
+                target_os = "freebsd",
                 target_os = "ios",
+                target_os = "macos",
+                target_os = "netbsd",
+                target_os = "openbsd",
             ))]
             libc::SCM_CREDS,
         )
diff --git a/library/std/src/sys/unix/ext/net/datagram.rs b/library/std/src/sys/unix/ext/net/datagram.rs
index 7225b3e5f66..5df45e6465b 100644
--- a/library/std/src/sys/unix/ext/net/datagram.rs
+++ b/library/std/src/sys/unix/ext/net/datagram.rs
@@ -4,6 +4,22 @@ use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
 use crate::path::Path;
 use crate::sys::unix::cvt;
 use crate::sys::unix::ext::net::addr::{sockaddr_un, SocketAddr};
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "solaris",
+    target_env = "uclibc",
+))]
 use crate::sys::unix::ext::net::ancillary::{
     recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary,
 };
@@ -346,6 +362,22 @@ impl UnixDatagram {
     ///     Ok(())
     /// }
     /// ```
+    #[cfg(any(
+        target_os = "android",
+        target_os = "dragonfly",
+        target_os = "emscripten",
+        target_os = "freebsd",
+        target_os = "fuchsia",
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "solaris",
+        target_env = "uclibc",
+    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn recv_vectored_with_ancillary_from(
         &self,
@@ -394,6 +426,22 @@ impl UnixDatagram {
     ///     Ok(())
     /// }
     /// ```
+    #[cfg(any(
+        target_os = "android",
+        target_os = "dragonfly",
+        target_os = "emscripten",
+        target_os = "freebsd",
+        target_os = "fuchsia",
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "solaris",
+        target_env = "uclibc",
+    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn recv_vectored_with_ancillary(
         &self,
diff --git a/library/std/src/sys/unix/ext/net/mod.rs b/library/std/src/sys/unix/ext/net/mod.rs
index 93b72df520a..125432b2b71 100644
--- a/library/std/src/sys/unix/ext/net/mod.rs
+++ b/library/std/src/sys/unix/ext/net/mod.rs
@@ -3,6 +3,22 @@
 #![stable(feature = "unix_socket", since = "1.10.0")]
 
 mod addr;
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "solaris",
+    target_env = "uclibc",
+))]
 mod ancillary;
 mod datagram;
 mod listener;
@@ -13,6 +29,22 @@ mod test;
 
 #[stable(feature = "unix_socket", since = "1.10.0")]
 pub use self::addr::*;
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "solaris",
+    target_env = "uclibc",
+))]
 #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
 pub use self::ancillary::*;
 #[stable(feature = "unix_socket", since = "1.10.0")]
diff --git a/library/std/src/sys/unix/ext/net/stream.rs b/library/std/src/sys/unix/ext/net/stream.rs
index 091026d6cfc..907832399d8 100644
--- a/library/std/src/sys/unix/ext/net/stream.rs
+++ b/library/std/src/sys/unix/ext/net/stream.rs
@@ -16,6 +16,22 @@ use crate::path::Path;
 use crate::sys::cvt;
 use crate::sys::net::Socket;
 use crate::sys::unix::ext::net::addr::{sockaddr_un, SocketAddr};
+#[cfg(any(
+    target_os = "android",
+    target_os = "dragonfly",
+    target_os = "emscripten",
+    target_os = "freebsd",
+    target_os = "fuchsia",
+    target_os = "haiku",
+    target_os = "illumos",
+    target_os = "ios",
+    target_os = "linux",
+    target_os = "macos",
+    target_os = "netbsd",
+    target_os = "openbsd",
+    target_os = "solaris",
+    target_env = "uclibc",
+))]
 use crate::sys::unix::ext::net::ancillary::{
     recv_vectored_with_ancillary_from, send_vectored_with_ancillary_to, SocketAncillary,
 };
@@ -458,6 +474,22 @@ impl UnixStream {
     ///     Ok(())
     /// }
     /// ```
+    #[cfg(any(
+        target_os = "android",
+        target_os = "dragonfly",
+        target_os = "emscripten",
+        target_os = "freebsd",
+        target_os = "fuchsia",
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "solaris",
+        target_env = "uclibc",
+    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn recv_vectored_with_ancillary(
         &self,
@@ -498,6 +530,22 @@ impl UnixStream {
     ///     Ok(())
     /// }
     /// ```
+    #[cfg(any(
+        target_os = "android",
+        target_os = "dragonfly",
+        target_os = "emscripten",
+        target_os = "freebsd",
+        target_os = "fuchsia",
+        target_os = "haiku",
+        target_os = "illumos",
+        target_os = "ios",
+        target_os = "linux",
+        target_os = "macos",
+        target_os = "netbsd",
+        target_os = "openbsd",
+        target_os = "solaris",
+        target_env = "uclibc",
+    ))]
     #[unstable(feature = "unix_socket_ancillary_data", issue = "none")]
     pub fn send_vectored_with_ancillary(
         &self,