net: add cygwin support (#7393)

This commit is contained in:
Yuyi Wang
2025-06-08 09:55:43 +02:00
committed by GitHub
parent c38de96b94
commit 38d88c6799
3 changed files with 31 additions and 7 deletions
+1
View File
@@ -30,4 +30,5 @@ unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(tokio_taskdump)',
'cfg(tokio_unstable)',
'cfg(tokio_uring)',
'cfg(target_os, values("cygwin"))',
] }
+24 -4
View File
@@ -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<bool> {
self.inner.reuse_port()
+6 -3
View File
@@ -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;