about summary refs log tree commit diff
path: root/library/std/src/sys
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/sys')
-rw-r--r--library/std/src/sys/anonymous_pipe/unix.rs94
-rw-r--r--library/std/src/sys/anonymous_pipe/unsupported.rs17
-rw-r--r--library/std/src/sys/anonymous_pipe/windows.rs101
-rw-r--r--library/std/src/sys/fs/unix.rs11
-rw-r--r--library/std/src/sys/net/connection/socket.rs3
-rw-r--r--library/std/src/sys/net/connection/socket/unix.rs14
-rw-r--r--library/std/src/sys/pal/unix/args.rs1
-rw-r--r--library/std/src/sys/pal/unix/env.rs11
-rw-r--r--library/std/src/sys/pal/unix/fd.rs4
-rw-r--r--library/std/src/sys/pal/unix/mod.rs2
-rw-r--r--library/std/src/sys/pal/unix/os.rs9
-rw-r--r--library/std/src/sys/pal/unix/pipe.rs1
-rw-r--r--library/std/src/sys/pal/unix/process/process_common.rs6
-rw-r--r--library/std/src/sys/pal/unix/process/process_unix.rs3
-rw-r--r--library/std/src/sys/pal/unix/thread.rs4
-rw-r--r--library/std/src/sys/pal/unsupported/pipe.rs51
-rw-r--r--library/std/src/sys/pal/windows/process.rs6
-rw-r--r--library/std/src/sys/personality/gcc.rs5
-rw-r--r--library/std/src/sys/random/getrandom.rs (renamed from library/std/src/sys/random/horizon.rs)0
-rw-r--r--library/std/src/sys/random/mod.rs8
20 files changed, 133 insertions, 218 deletions
diff --git a/library/std/src/sys/anonymous_pipe/unix.rs b/library/std/src/sys/anonymous_pipe/unix.rs
index 9e398765634..dfe10f7fafe 100644
--- a/library/std/src/sys/anonymous_pipe/unix.rs
+++ b/library/std/src/sys/anonymous_pipe/unix.rs
@@ -1,9 +1,7 @@
-use crate::io::{self, PipeReader, PipeWriter};
-use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
-use crate::process::Stdio;
+use crate::io;
 use crate::sys::fd::FileDesc;
 use crate::sys::pipe::anon_pipe;
-use crate::sys_common::{FromInner, IntoInner};
+use crate::sys_common::IntoInner;
 
 pub type AnonPipe = FileDesc;
 
@@ -11,91 +9,3 @@ pub type AnonPipe = FileDesc;
 pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
     anon_pipe().map(|(rx, wx)| (rx.into_inner(), wx.into_inner()))
 }
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsFd for PipeReader {
-    fn as_fd(&self) -> BorrowedFd<'_> {
-        self.0.as_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsRawFd for PipeReader {
-    fn as_raw_fd(&self) -> RawFd {
-        self.0.as_raw_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeReader> for OwnedFd {
-    fn from(pipe: PipeReader) -> Self {
-        FileDesc::into_inner(pipe.0)
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl FromRawFd for PipeReader {
-    unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
-        unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl IntoRawFd for PipeReader {
-    fn into_raw_fd(self) -> RawFd {
-        self.0.into_raw_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeReader> for Stdio {
-    fn from(pipe: PipeReader) -> Self {
-        Self::from(OwnedFd::from(pipe))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsFd for PipeWriter {
-    fn as_fd(&self) -> BorrowedFd<'_> {
-        self.0.as_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsRawFd for PipeWriter {
-    fn as_raw_fd(&self) -> RawFd {
-        self.0.as_raw_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeWriter> for OwnedFd {
-    fn from(pipe: PipeWriter) -> Self {
-        FileDesc::into_inner(pipe.0)
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl FromRawFd for PipeWriter {
-    unsafe fn from_raw_fd(raw_fd: RawFd) -> Self {
-        unsafe { Self(FileDesc::from_raw_fd(raw_fd)) }
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl IntoRawFd for PipeWriter {
-    fn into_raw_fd(self) -> RawFd {
-        self.0.into_raw_fd()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeWriter> for Stdio {
-    fn from(pipe: PipeWriter) -> Self {
-        Self::from(OwnedFd::from(pipe))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<OwnedFd> for PipeReader {
-    fn from(owned_fd: OwnedFd) -> Self {
-        Self(FileDesc::from_inner(owned_fd))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<OwnedFd> for PipeWriter {
-    fn from(owned_fd: OwnedFd) -> Self {
-        Self(FileDesc::from_inner(owned_fd))
-    }
-}
diff --git a/library/std/src/sys/anonymous_pipe/unsupported.rs b/library/std/src/sys/anonymous_pipe/unsupported.rs
index 4e79ac9c21a..a0805ba9540 100644
--- a/library/std/src/sys/anonymous_pipe/unsupported.rs
+++ b/library/std/src/sys/anonymous_pipe/unsupported.rs
@@ -1,22 +1,7 @@
-use crate::io::{self, PipeReader, PipeWriter};
-use crate::process::Stdio;
+use crate::io;
 pub use crate::sys::pipe::AnonPipe;
 
 #[inline]
 pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
     Err(io::Error::UNSUPPORTED_PLATFORM)
 }
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeReader> for Stdio {
-    fn from(pipe: PipeReader) -> Self {
-        pipe.0.diverge()
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeWriter> for Stdio {
-    fn from(pipe: PipeWriter) -> Self {
-        pipe.0.diverge()
-    }
-}
diff --git a/library/std/src/sys/anonymous_pipe/windows.rs b/library/std/src/sys/anonymous_pipe/windows.rs
index eb7fa8ec1c9..bdda7ffc5d2 100644
--- a/library/std/src/sys/anonymous_pipe/windows.rs
+++ b/library/std/src/sys/anonymous_pipe/windows.rs
@@ -1,12 +1,7 @@
-use crate::io::{self, PipeReader, PipeWriter};
-use crate::os::windows::io::{
-    AsHandle, AsRawHandle, BorrowedHandle, FromRawHandle, IntoRawHandle, OwnedHandle, RawHandle,
-};
-use crate::process::Stdio;
-use crate::ptr;
+use crate::os::windows::io::FromRawHandle;
 use crate::sys::c;
 use crate::sys::handle::Handle;
-use crate::sys_common::{FromInner, IntoInner};
+use crate::{io, ptr};
 
 pub type AnonPipe = Handle;
 
@@ -22,95 +17,3 @@ pub fn pipe() -> io::Result<(AnonPipe, AnonPipe)> {
         unsafe { Ok((Handle::from_raw_handle(read_pipe), Handle::from_raw_handle(write_pipe))) }
     }
 }
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsHandle for PipeReader {
-    fn as_handle(&self) -> BorrowedHandle<'_> {
-        self.0.as_handle()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsRawHandle for PipeReader {
-    fn as_raw_handle(&self) -> RawHandle {
-        self.0.as_raw_handle()
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl FromRawHandle for PipeReader {
-    unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
-        unsafe { Self(Handle::from_raw_handle(raw_handle)) }
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl IntoRawHandle for PipeReader {
-    fn into_raw_handle(self) -> RawHandle {
-        self.0.into_raw_handle()
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeReader> for OwnedHandle {
-    fn from(pipe: PipeReader) -> Self {
-        Handle::into_inner(pipe.0)
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeReader> for Stdio {
-    fn from(pipe: PipeReader) -> Self {
-        Self::from(OwnedHandle::from(pipe))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsHandle for PipeWriter {
-    fn as_handle(&self) -> BorrowedHandle<'_> {
-        self.0.as_handle()
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl AsRawHandle for PipeWriter {
-    fn as_raw_handle(&self) -> RawHandle {
-        self.0.as_raw_handle()
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl FromRawHandle for PipeWriter {
-    unsafe fn from_raw_handle(raw_handle: RawHandle) -> Self {
-        unsafe { Self(Handle::from_raw_handle(raw_handle)) }
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl IntoRawHandle for PipeWriter {
-    fn into_raw_handle(self) -> RawHandle {
-        self.0.into_raw_handle()
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeWriter> for OwnedHandle {
-    fn from(pipe: PipeWriter) -> Self {
-        Handle::into_inner(pipe.0)
-    }
-}
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<PipeWriter> for Stdio {
-    fn from(pipe: PipeWriter) -> Self {
-        Self::from(OwnedHandle::from(pipe))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<OwnedHandle> for PipeReader {
-    fn from(owned_handle: OwnedHandle) -> Self {
-        Self(Handle::from_inner(owned_handle))
-    }
-}
-
-#[unstable(feature = "anonymous_pipe", issue = "127154")]
-impl From<OwnedHandle> for PipeWriter {
-    fn from(owned_handle: OwnedHandle) -> Self {
-        Self(Handle::from_inner(owned_handle))
-    }
-}
diff --git a/library/std/src/sys/fs/unix.rs b/library/std/src/sys/fs/unix.rs
index d944bc9c9a2..7c3ed8029f7 100644
--- a/library/std/src/sys/fs/unix.rs
+++ b/library/std/src/sys/fs/unix.rs
@@ -543,7 +543,12 @@ impl FileAttr {
         SystemTime::new(self.stat.st_atim.tv_sec as i64, self.stat.st_atim.tv_nsec as i64)
     }
 
-    #[cfg(any(target_os = "freebsd", target_os = "openbsd", target_vendor = "apple"))]
+    #[cfg(any(
+        target_os = "freebsd",
+        target_os = "openbsd",
+        target_vendor = "apple",
+        target_os = "cygwin",
+    ))]
     pub fn created(&self) -> io::Result<SystemTime> {
         SystemTime::new(self.stat.st_birthtime as i64, self.stat.st_birthtime_nsec as i64)
     }
@@ -553,6 +558,7 @@ impl FileAttr {
         target_os = "openbsd",
         target_os = "vita",
         target_vendor = "apple",
+        target_os = "cygwin",
     )))]
     pub fn created(&self) -> io::Result<SystemTime> {
         cfg_has_statx! {
@@ -960,6 +966,7 @@ impl DirEntry {
 
     #[cfg(any(
         target_os = "linux",
+        target_os = "cygwin",
         target_os = "emscripten",
         target_os = "android",
         target_os = "solaris",
@@ -1220,6 +1227,7 @@ impl File {
             target_os = "freebsd",
             target_os = "fuchsia",
             target_os = "linux",
+            target_os = "cygwin",
             target_os = "android",
             target_os = "netbsd",
             target_os = "openbsd",
@@ -1234,6 +1242,7 @@ impl File {
             target_os = "fuchsia",
             target_os = "freebsd",
             target_os = "linux",
+            target_os = "cygwin",
             target_os = "netbsd",
             target_os = "openbsd",
             target_os = "nto",
diff --git a/library/std/src/sys/net/connection/socket.rs b/library/std/src/sys/net/connection/socket.rs
index e154cf039ca..7301bde6881 100644
--- a/library/std/src/sys/net/connection/socket.rs
+++ b/library/std/src/sys/net/connection/socket.rs
@@ -59,7 +59,8 @@ cfg_if::cfg_if! {
         target_os = "dragonfly", target_os = "freebsd",
         target_os = "openbsd", target_os = "netbsd",
         target_os = "solaris", target_os = "illumos",
-        target_os = "haiku", target_os = "nto"))] {
+        target_os = "haiku", target_os = "nto",
+        target_os = "cygwin"))] {
         use libc::MSG_NOSIGNAL;
     } else {
         const MSG_NOSIGNAL: c_int = 0x0;
diff --git a/library/std/src/sys/net/connection/socket/unix.rs b/library/std/src/sys/net/connection/socket/unix.rs
index e633cf772c5..bbe1e038dcc 100644
--- a/library/std/src/sys/net/connection/socket/unix.rs
+++ b/library/std/src/sys/net/connection/socket/unix.rs
@@ -81,6 +81,7 @@ impl Socket {
                     target_os = "linux",
                     target_os = "netbsd",
                     target_os = "openbsd",
+                    target_os = "cygwin",
                     target_os = "nto",
                     target_os = "solaris",
                 ))] {
@@ -128,6 +129,7 @@ impl Socket {
                     target_os = "hurd",
                     target_os = "netbsd",
                     target_os = "openbsd",
+                    target_os = "cygwin",
                     target_os = "nto",
                 ))] {
                     // Like above, set cloexec atomically
@@ -257,6 +259,7 @@ impl Socket {
                 target_os = "hurd",
                 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))?;
@@ -421,6 +424,7 @@ impl Socket {
         Ok(())
     }
 
+    #[cfg(not(target_os = "cygwin"))]
     pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
         let linger = libc::linger {
             l_onoff: linger.is_some() as libc::c_int,
@@ -430,6 +434,16 @@ impl Socket {
         setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
     }
 
+    #[cfg(target_os = "cygwin")]
+    pub fn set_linger(&self, linger: Option<Duration>) -> io::Result<()> {
+        let linger = libc::linger {
+            l_onoff: linger.is_some() as libc::c_ushort,
+            l_linger: linger.unwrap_or_default().as_secs() as libc::c_ushort,
+        };
+
+        setsockopt(self, libc::SOL_SOCKET, SO_LINGER, linger)
+    }
+
     pub fn linger(&self) -> io::Result<Option<Duration>> {
         let val: libc::linger = getsockopt(self, libc::SOL_SOCKET, SO_LINGER)?;
 
diff --git a/library/std/src/sys/pal/unix/args.rs b/library/std/src/sys/pal/unix/args.rs
index 1c87a79803c..0bb7b64007a 100644
--- a/library/std/src/sys/pal/unix/args.rs
+++ b/library/std/src/sys/pal/unix/args.rs
@@ -100,6 +100,7 @@ impl DoubleEndedIterator for Args {
     target_os = "dragonfly",
     target_os = "netbsd",
     target_os = "openbsd",
+    target_os = "cygwin",
     target_os = "solaris",
     target_os = "illumos",
     target_os = "emscripten",
diff --git a/library/std/src/sys/pal/unix/env.rs b/library/std/src/sys/pal/unix/env.rs
index 2aee0b5d460..c6609298f4b 100644
--- a/library/std/src/sys/pal/unix/env.rs
+++ b/library/std/src/sys/pal/unix/env.rs
@@ -108,6 +108,17 @@ pub mod os {
     pub const EXE_EXTENSION: &str = "";
 }
 
+#[cfg(target_os = "cygwin")]
+pub mod os {
+    pub const FAMILY: &str = "unix";
+    pub const OS: &str = "cygwin";
+    pub const DLL_PREFIX: &str = "";
+    pub const DLL_SUFFIX: &str = ".dll";
+    pub const DLL_EXTENSION: &str = "dll";
+    pub const EXE_SUFFIX: &str = ".exe";
+    pub const EXE_EXTENSION: &str = "exe";
+}
+
 #[cfg(target_os = "android")]
 pub mod os {
     pub const FAMILY: &str = "unix";
diff --git a/library/std/src/sys/pal/unix/fd.rs b/library/std/src/sys/pal/unix/fd.rs
index a08c7ccec2d..f03c440e30e 100644
--- a/library/std/src/sys/pal/unix/fd.rs
+++ b/library/std/src/sys/pal/unix/fd.rs
@@ -47,6 +47,7 @@ const READ_LIMIT: usize = if cfg!(target_vendor = "apple") {
     target_os = "netbsd",
     target_os = "openbsd",
     target_vendor = "apple",
+    target_os = "cygwin",
 ))]
 const fn max_iov() -> usize {
     libc::IOV_MAX as usize
@@ -74,6 +75,7 @@ const fn max_iov() -> usize {
     target_os = "horizon",
     target_os = "vita",
     target_vendor = "apple",
+    target_os = "cygwin",
 )))]
 const fn max_iov() -> usize {
     16 // The minimum value required by POSIX.
@@ -503,6 +505,7 @@ impl FileDesc {
         target_os = "fuchsia",
         target_os = "l4re",
         target_os = "linux",
+        target_os = "cygwin",
         target_os = "haiku",
         target_os = "redox",
         target_os = "vxworks",
@@ -525,6 +528,7 @@ impl FileDesc {
         target_os = "fuchsia",
         target_os = "l4re",
         target_os = "linux",
+        target_os = "cygwin",
         target_os = "haiku",
         target_os = "redox",
         target_os = "vxworks",
diff --git a/library/std/src/sys/pal/unix/mod.rs b/library/std/src/sys/pal/unix/mod.rs
index 419abe732ac..e2e537b7bd3 100644
--- a/library/std/src/sys/pal/unix/mod.rs
+++ b/library/std/src/sys/pal/unix/mod.rs
@@ -380,7 +380,7 @@ cfg_if::cfg_if! {
         #[link(name = "pthread")]
         #[link(name = "rt")]
         unsafe extern "C" {}
-    } else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd"))] {
+    } else if #[cfg(any(target_os = "dragonfly", target_os = "openbsd", target_os = "cygwin"))] {
         #[link(name = "pthread")]
         unsafe extern "C" {}
     } else if #[cfg(target_os = "solaris")] {
diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs
index 91f55fcd32b..30282fbf655 100644
--- a/library/std/src/sys/pal/unix/os.rs
+++ b/library/std/src/sys/pal/unix/os.rs
@@ -46,6 +46,7 @@ unsafe extern "C" {
         any(
             target_os = "netbsd",
             target_os = "openbsd",
+            target_os = "cygwin",
             target_os = "android",
             target_os = "redox",
             target_os = "nuttx",
@@ -118,7 +119,12 @@ pub fn error_string(errno: i32) -> String {
     unsafe extern "C" {
         #[cfg_attr(
             all(
-                any(target_os = "linux", target_os = "hurd", target_env = "newlib"),
+                any(
+                    target_os = "linux",
+                    target_os = "hurd",
+                    target_env = "newlib",
+                    target_os = "cygwin"
+                ),
                 not(target_env = "ohos")
             ),
             link_name = "__xpg_strerror_r"
@@ -395,6 +401,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
 
 #[cfg(any(
     target_os = "linux",
+    target_os = "cygwin",
     target_os = "hurd",
     target_os = "android",
     target_os = "nuttx",
diff --git a/library/std/src/sys/pal/unix/pipe.rs b/library/std/src/sys/pal/unix/pipe.rs
index 4a992e32a91..55510153dc8 100644
--- a/library/std/src/sys/pal/unix/pipe.rs
+++ b/library/std/src/sys/pal/unix/pipe.rs
@@ -27,6 +27,7 @@ pub fn anon_pipe() -> io::Result<(AnonPipe, AnonPipe)> {
             target_os = "linux",
             target_os = "netbsd",
             target_os = "openbsd",
+            target_os = "cygwin",
             target_os = "redox"
         ))] {
             unsafe {
diff --git a/library/std/src/sys/pal/unix/process/process_common.rs b/library/std/src/sys/pal/unix/process/process_common.rs
index dd41921f263..a1c747c8df4 100644
--- a/library/std/src/sys/pal/unix/process/process_common.rs
+++ b/library/std/src/sys/pal/unix/process/process_common.rs
@@ -489,6 +489,12 @@ impl From<AnonPipe> for Stdio {
     }
 }
 
+impl From<FileDesc> for Stdio {
+    fn from(fd: FileDesc) -> Stdio {
+        Stdio::Fd(fd)
+    }
+}
+
 impl From<File> for Stdio {
     fn from(file: File) -> Stdio {
         Stdio::Fd(file.into_inner())
diff --git a/library/std/src/sys/pal/unix/process/process_unix.rs b/library/std/src/sys/pal/unix/process/process_unix.rs
index be9a7e91990..f19512233d8 100644
--- a/library/std/src/sys/pal/unix/process/process_unix.rs
+++ b/library/std/src/sys/pal/unix/process/process_unix.rs
@@ -1157,7 +1157,7 @@ fn signal_string(signal: i32) -> &'static str {
             )
         ))]
         libc::SIGSTKFLT => " (SIGSTKFLT)",
-        #[cfg(any(target_os = "linux", target_os = "nto"))]
+        #[cfg(any(target_os = "linux", target_os = "nto", target_os = "cygwin"))]
         libc::SIGPWR => " (SIGPWR)",
         #[cfg(any(
             target_os = "freebsd",
@@ -1166,6 +1166,7 @@ fn signal_string(signal: i32) -> &'static str {
             target_os = "dragonfly",
             target_os = "nto",
             target_vendor = "apple",
+            target_os = "cygwin",
         ))]
         libc::SIGEMT => " (SIGEMT)",
         #[cfg(any(
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index abe8d3fbf68..bffe2536299 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -137,7 +137,8 @@ impl Thread {
         target_os = "linux",
         target_os = "freebsd",
         target_os = "dragonfly",
-        target_os = "nuttx"
+        target_os = "nuttx",
+        target_os = "cygwin"
     ))]
     pub fn set_name(name: &CStr) {
         unsafe {
@@ -365,6 +366,7 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
             target_os = "linux",
             target_os = "aix",
             target_vendor = "apple",
+            target_os = "cygwin",
         ))] {
             #[allow(unused_assignments)]
             #[allow(unused_mut)]
diff --git a/library/std/src/sys/pal/unsupported/pipe.rs b/library/std/src/sys/pal/unsupported/pipe.rs
index 6799d21a1ff..988e551de52 100644
--- a/library/std/src/sys/pal/unsupported/pipe.rs
+++ b/library/std/src/sys/pal/unsupported/pipe.rs
@@ -1,5 +1,6 @@
 use crate::fmt;
 use crate::io::{self, BorrowedCursor, IoSlice, IoSliceMut};
+use crate::sys_common::{FromInner, IntoInner};
 
 pub struct AnonPipe(!);
 
@@ -54,3 +55,53 @@ impl AnonPipe {
 pub fn read2(p1: AnonPipe, _v1: &mut Vec<u8>, _p2: AnonPipe, _v2: &mut Vec<u8>) -> io::Result<()> {
     match p1.0 {}
 }
+
+impl FromInner<!> for AnonPipe {
+    fn from_inner(inner: !) -> Self {
+        inner
+    }
+}
+
+impl IntoInner<!> for AnonPipe {
+    fn into_inner(self) -> ! {
+        self.0
+    }
+}
+
+#[cfg(any(unix, target_os = "hermit", target_os = "wasi"))]
+mod unix_traits {
+    use super::AnonPipe;
+    use crate::os::fd::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd};
+    use crate::sys_common::FromInner;
+
+    impl AsRawFd for AnonPipe {
+        #[inline]
+        fn as_raw_fd(&self) -> RawFd {
+            self.0
+        }
+    }
+
+    impl AsFd for AnonPipe {
+        fn as_fd(&self) -> BorrowedFd<'_> {
+            self.0
+        }
+    }
+
+    impl IntoRawFd for AnonPipe {
+        fn into_raw_fd(self) -> RawFd {
+            self.0
+        }
+    }
+
+    impl FromRawFd for AnonPipe {
+        unsafe fn from_raw_fd(_: RawFd) -> Self {
+            panic!("creating pipe on this platform is unsupported!")
+        }
+    }
+
+    impl FromInner<OwnedFd> for AnonPipe {
+        fn from_inner(_: OwnedFd) -> Self {
+            panic!("creating pipe on this platform is unsupported!")
+        }
+    }
+}
diff --git a/library/std/src/sys/pal/windows/process.rs b/library/std/src/sys/pal/windows/process.rs
index c57ff355d12..50e4baba607 100644
--- a/library/std/src/sys/pal/windows/process.rs
+++ b/library/std/src/sys/pal/windows/process.rs
@@ -621,6 +621,12 @@ impl From<AnonPipe> for Stdio {
     }
 }
 
+impl From<Handle> for Stdio {
+    fn from(pipe: Handle) -> Stdio {
+        Stdio::Handle(pipe)
+    }
+}
+
 impl From<File> for Stdio {
     fn from(file: File) -> Stdio {
         Stdio::Handle(file.into_inner())
diff --git a/library/std/src/sys/personality/gcc.rs b/library/std/src/sys/personality/gcc.rs
index 9a5b3b2fd19..b012e47f9aa 100644
--- a/library/std/src/sys/personality/gcc.rs
+++ b/library/std/src/sys/personality/gcc.rs
@@ -248,7 +248,10 @@ cfg_if::cfg_if! {
         }
 
         cfg_if::cfg_if! {
-            if #[cfg(all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), target_env = "gnu"))] {
+            if #[cfg(any(
+                    all(windows, any(target_arch = "aarch64", target_arch = "x86_64"), target_env = "gnu"),
+                    target_os = "cygwin",
+                ))] {
                 /// personality fn called by [Windows Structured Exception Handling][windows-eh]
                 ///
                 /// On x86_64 and AArch64 MinGW targets, the unwinding mechanism is SEH,
diff --git a/library/std/src/sys/random/horizon.rs b/library/std/src/sys/random/getrandom.rs
index 0be2eae20a7..0be2eae20a7 100644
--- a/library/std/src/sys/random/horizon.rs
+++ b/library/std/src/sys/random/getrandom.rs
diff --git a/library/std/src/sys/random/mod.rs b/library/std/src/sys/random/mod.rs
index 870039602bc..013e886a99b 100644
--- a/library/std/src/sys/random/mod.rs
+++ b/library/std/src/sys/random/mod.rs
@@ -35,10 +35,10 @@ cfg_if::cfg_if! {
     } else if #[cfg(target_os = "hermit")] {
         mod hermit;
         pub use hermit::fill_bytes;
-    } else if #[cfg(target_os = "horizon")] {
-        // FIXME: add arc4random_buf to shim-3ds
-        mod horizon;
-        pub use horizon::fill_bytes;
+    } else if #[cfg(any(target_os = "horizon", target_os = "cygwin"))] {
+        // FIXME(horizon): add arc4random_buf to shim-3ds
+        mod getrandom;
+        pub use getrandom::fill_bytes;
     } else if #[cfg(any(
         target_os = "aix",
         target_os = "hurd",