about summary refs log tree commit diff
path: root/library/std/src/sys/net/connection/socket/unix.rs
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys/net/connection/socket/unix.rs')
-rw-r--r--library/std/src/sys/net/connection/socket/unix.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs
index cc111f3521b..8b5970d1494 100644
--- a/library/std/src/sys/net/connection/socket/unix.rs
+++ b/library/std/src/sys/net/connection/socket/unix.rs
@@ -12,10 +12,11 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
 use crate::time::{Duration, Instant};
 use crate::{cmp, mem};
 
-cfg_if::cfg_if! {
-    if #[cfg(target_vendor = "apple")] {
+cfg_select! {
+    target_vendor = "apple" => {
         use libc::SO_LINGER_SEC as SO_LINGER;
-    } else {
+    }
+    _ => {
         use libc::SO_LINGER;
     }
 }
@@ -72,8 +73,8 @@ impl Socket {
 
     pub fn new_raw(fam: c_int, ty: c_int) -> io::Result<Socket> {
         unsafe {
-            cfg_if::cfg_if! {
-                if #[cfg(any(
+            cfg_select! {
+                any(
                     target_os = "android",
                     target_os = "dragonfly",
                     target_os = "freebsd",
@@ -85,7 +86,7 @@ impl Socket {
                     target_os = "cygwin",
                     target_os = "nto",
                     target_os = "solaris",
-                ))] {
+                ) => {
                     // On platforms that support it we pass the SOCK_CLOEXEC
                     // flag to atomically create the socket and set it as
                     // CLOEXEC. On Linux this was added in 2.6.27.
@@ -98,7 +99,8 @@ impl Socket {
                     setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;
 
                     Ok(socket)
-                } else {
+                }
+                _ => {
                     let fd = cvt(libc::socket(fam, ty, 0))?;
                     let fd = FileDesc::from_raw_fd(fd);
                     fd.set_cloexec()?;
@@ -120,8 +122,8 @@ impl Socket {
         unsafe {
             let mut fds = [0, 0];
 
-            cfg_if::cfg_if! {
-                if #[cfg(any(
+            cfg_select! {
+                any(
                     target_os = "android",
                     target_os = "dragonfly",
                     target_os = "freebsd",
@@ -132,11 +134,12 @@ impl Socket {
                     target_os = "openbsd",
                     target_os = "cygwin",
                     target_os = "nto",
-                ))] {
+                ) => {
                     // Like above, set cloexec atomically
                     cvt(libc::socketpair(fam, ty | libc::SOCK_CLOEXEC, 0, fds.as_mut_ptr()))?;
                     Ok((Socket(FileDesc::from_raw_fd(fds[0])), Socket(FileDesc::from_raw_fd(fds[1]))))
-                } else {
+                }
+                _ => {
                     cvt(libc::socketpair(fam, ty, 0, fds.as_mut_ptr()))?;
                     let a = FileDesc::from_raw_fd(fds[0]);
                     let b = FileDesc::from_raw_fd(fds[1]);
@@ -250,8 +253,8 @@ impl Socket {
         // atomically set the CLOEXEC flag is to use the `accept4` syscall on
         // platforms that support it. On Linux, this was added in 2.6.28,
         // glibc 2.10 and musl 0.9.5.
-        cfg_if::cfg_if! {
-            if #[cfg(any(
+        cfg_select! {
+            any(
                 target_os = "android",
                 target_os = "dragonfly",
                 target_os = "freebsd",
@@ -261,12 +264,13 @@ impl Socket {
                 target_os = "netbsd",
                 target_os = "openbsd",
                 target_os = "cygwin",
-            ))] {
+            ) => {
                 unsafe {
                     let fd = cvt_r(|| libc::accept4(self.as_raw_fd(), storage, len, libc::SOCK_CLOEXEC))?;
                     Ok(Socket(FileDesc::from_raw_fd(fd)))
                 }
-            } else {
+            }
+            _ => {
                 unsafe {
                     let fd = cvt_r(|| libc::accept(self.as_raw_fd(), storage, len))?;
                     let fd = FileDesc::from_raw_fd(fd);