From 7534b2010b2acb17f2c8df87835871c1e50c3e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Sat, 7 Jun 2025 14:47:55 +0800 Subject: [PATCH 1/2] net: add cygwin support --- tokio/src/net/tcp/socket.rs | 28 ++++++++++++++++++++++++---- tokio/src/net/unix/ucred.rs | 9 ++++++--- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/tokio/src/net/tcp/socket.rs b/tokio/src/net/tcp/socket.rs index 340e8e89a60..9dc1ec9e9b8 100644 --- a/tokio/src/net/tcp/socket.rs +++ b/tokio/src/net/tcp/socket.rs @@ -276,10 +276,20 @@ impl TcpSocket { /// Ok(()) /// } /// ``` - #[cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))] + #[cfg(all( + unix, + not(target_os = "solaris"), + not(target_os = "illumos"), + not(target_os = "cygwin"), + ))] #[cfg_attr( docsrs, - doc(cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))) + doc(cfg(all( + unix, + not(target_os = "solaris"), + not(target_os = "illumos"), + not(target_os = "cygwin"), + ))) )] pub fn set_reuseport(&self, reuseport: bool) -> io::Result<()> { self.inner.set_reuse_port(reuseport) @@ -311,10 +321,20 @@ impl TcpSocket { /// Ok(()) /// } /// ``` - #[cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))] + #[cfg(all( + unix, + not(target_os = "solaris"), + not(target_os = "illumos"), + not(target_os = "cygwin"), + ))] #[cfg_attr( docsrs, - doc(cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))) + doc(cfg(all( + unix, + not(target_os = "solaris"), + not(target_os = "illumos"), + not(target_os = "cygwin"), + ))) )] pub fn reuseport(&self) -> io::Result { self.inner.reuse_port() diff --git a/tokio/src/net/unix/ucred.rs b/tokio/src/net/unix/ucred.rs index 74e596bc9b6..bdc417f1304 100644 --- a/tokio/src/net/unix/ucred.rs +++ b/tokio/src/net/unix/ucred.rs @@ -36,7 +36,8 @@ impl UCred { target_os = "redox", target_os = "android", target_os = "openbsd", - target_os = "haiku" + target_os = "haiku", + target_os = "cygwin" ))] pub(crate) use self::impl_linux::get_peer_cred; @@ -69,7 +70,8 @@ pub(crate) use self::impl_noproc::get_peer_cred; target_os = "redox", target_os = "android", target_os = "openbsd", - target_os = "haiku" + target_os = "haiku", + target_os = "cygwin" ))] pub(crate) mod impl_linux { use crate::net::unix::{self, UnixStream}; @@ -83,7 +85,8 @@ pub(crate) mod impl_linux { target_os = "linux", target_os = "redox", target_os = "android", - target_os = "haiku" + target_os = "haiku", + target_os = "cygwin" ))] use libc::ucred; From 8ca8a3c183d72ec62b73d591d1f19f32d72984e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=87=E9=80=B8?= Date: Sat, 7 Jun 2025 15:35:39 +0800 Subject: [PATCH 2/2] ci: ignore target_os = "cygwin" --- Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/Cargo.toml b/Cargo.toml index 7ecb6eea0c7..6ed579b136d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,4 +30,5 @@ unexpected_cfgs = { level = "warn", check-cfg = [ 'cfg(tokio_taskdump)', 'cfg(tokio_unstable)', 'cfg(tokio_uring)', + 'cfg(target_os, values("cygwin"))', ] }