about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-12-19 11:33:00 +0000
committerbors <bors@rust-lang.org>2019-12-19 11:33:00 +0000
commit0de96d37fbcc54978458c18f5067cd9817669bc8 (patch)
tree9fb998a8d7f0d19bc4ad5a7e37ee1fa694e27de6 /src/libstd/sys
parentc605199e89572e586a5f37bc698c48b6a10896fb (diff)
parent06985c68592112ef256eb08140f38a30b602d35c (diff)
downloadrust-0de96d37fbcc54978458c18f5067cd9817669bc8.tar.gz
rust-0de96d37fbcc54978458c18f5067cd9817669bc8.zip
Auto merge of #67419 - Centril:rollup-v7b0ypv, r=Centril
Rollup of 8 pull requests

Successful merges:

 - #67189 (Unify binop wording)
 - #67270 (std: Implement `LineWriter::write_vectored`)
 - #67286 (Fix the configure.py TOML field for a couple LLVM options)
 - #67321 (make htons const fn)
 - #67382 (Remove some unnecessary `ATTR_*` constants.)
 - #67389 (Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.)
 - #67394 (Remove outdated references to @T from comments)
 - #67406 (Suggest associated type when the specified one cannot be found)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/unix/net.rs17
-rw-r--r--src/libstd/sys/vxworks/net.rs1
2 files changed, 6 insertions, 12 deletions
diff --git a/src/libstd/sys/unix/net.rs b/src/libstd/sys/unix/net.rs
index 946b2b9d8de..5d101ed1f2e 100644
--- a/src/libstd/sys/unix/net.rs
+++ b/src/libstd/sys/unix/net.rs
@@ -28,14 +28,6 @@ use libc::SOCK_CLOEXEC;
 #[cfg(not(target_os = "linux"))]
 const SOCK_CLOEXEC: c_int = 0;
 
-// Another conditional constant for name resolution: Macos et iOS use
-// SO_NOSIGPIPE as a setsockopt flag to disable SIGPIPE emission on socket.
-// Other platforms do otherwise.
-#[cfg(target_vendor = "apple")]
-use libc::SO_NOSIGPIPE;
-#[cfg(not(target_vendor = "apple"))]
-const SO_NOSIGPIPE: c_int = 0;
-
 pub struct Socket(FileDesc);
 
 pub fn init() {}
@@ -89,9 +81,12 @@ impl Socket {
             let fd = FileDesc::new(fd);
             fd.set_cloexec()?;
             let socket = Socket(fd);
-            if cfg!(target_vendor = "apple") {
-                setsockopt(&socket, libc::SOL_SOCKET, SO_NOSIGPIPE, 1)?;
-            }
+
+            // macOS and iOS use `SO_NOSIGPIPE` as a `setsockopt`
+            // flag to disable `SIGPIPE` emission on socket.
+            #[cfg(target_vendor = "apple")]
+            setsockopt(&socket, libc::SOL_SOCKET, libc::SO_NOSIGPIPE, 1)?;
+
             Ok(socket)
         }
     }
diff --git a/src/libstd/sys/vxworks/net.rs b/src/libstd/sys/vxworks/net.rs
index 85f5fcff2c2..54466ff2c2e 100644
--- a/src/libstd/sys/vxworks/net.rs
+++ b/src/libstd/sys/vxworks/net.rs
@@ -19,7 +19,6 @@ pub extern crate libc as netc;
 pub type wrlen_t = size_t;
 
 const SOCK_CLOEXEC: c_int = 0;
-const SO_NOSIGPIPE: c_int = 0;
 
 pub struct Socket(FileDesc);