Skip to content

Commit 38d88c6

Browse files
authored
net: add cygwin support (#7393)
1 parent c38de96 commit 38d88c6

File tree

3 files changed

+31
-7
lines changed

3 files changed

+31
-7
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ unexpected_cfgs = { level = "warn", check-cfg = [
3030
'cfg(tokio_taskdump)',
3131
'cfg(tokio_unstable)',
3232
'cfg(tokio_uring)',
33+
'cfg(target_os, values("cygwin"))',
3334
] }

tokio/src/net/tcp/socket.rs

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,20 @@ impl TcpSocket {
276276
/// Ok(())
277277
/// }
278278
/// ```
279-
#[cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))]
279+
#[cfg(all(
280+
unix,
281+
not(target_os = "solaris"),
282+
not(target_os = "illumos"),
283+
not(target_os = "cygwin"),
284+
))]
280285
#[cfg_attr(
281286
docsrs,
282-
doc(cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos"))))
287+
doc(cfg(all(
288+
unix,
289+
not(target_os = "solaris"),
290+
not(target_os = "illumos"),
291+
not(target_os = "cygwin"),
292+
)))
283293
)]
284294
pub fn set_reuseport(&self, reuseport: bool) -> io::Result<()> {
285295
self.inner.set_reuse_port(reuseport)
@@ -311,10 +321,20 @@ impl TcpSocket {
311321
/// Ok(())
312322
/// }
313323
/// ```
314-
#[cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos")))]
324+
#[cfg(all(
325+
unix,
326+
not(target_os = "solaris"),
327+
not(target_os = "illumos"),
328+
not(target_os = "cygwin"),
329+
))]
315330
#[cfg_attr(
316331
docsrs,
317-
doc(cfg(all(unix, not(target_os = "solaris"), not(target_os = "illumos"))))
332+
doc(cfg(all(
333+
unix,
334+
not(target_os = "solaris"),
335+
not(target_os = "illumos"),
336+
not(target_os = "cygwin"),
337+
)))
318338
)]
319339
pub fn reuseport(&self) -> io::Result<bool> {
320340
self.inner.reuse_port()

tokio/src/net/unix/ucred.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ impl UCred {
3636
target_os = "redox",
3737
target_os = "android",
3838
target_os = "openbsd",
39-
target_os = "haiku"
39+
target_os = "haiku",
40+
target_os = "cygwin"
4041
))]
4142
pub(crate) use self::impl_linux::get_peer_cred;
4243

@@ -69,7 +70,8 @@ pub(crate) use self::impl_noproc::get_peer_cred;
6970
target_os = "redox",
7071
target_os = "android",
7172
target_os = "openbsd",
72-
target_os = "haiku"
73+
target_os = "haiku",
74+
target_os = "cygwin"
7375
))]
7476
pub(crate) mod impl_linux {
7577
use crate::net::unix::{self, UnixStream};
@@ -83,7 +85,8 @@ pub(crate) mod impl_linux {
8385
target_os = "linux",
8486
target_os = "redox",
8587
target_os = "android",
86-
target_os = "haiku"
88+
target_os = "haiku",
89+
target_os = "cygwin"
8790
))]
8891
use libc::ucred;
8992

0 commit comments

Comments
 (0)