Skip to content

Add cygwin support #568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ jobs:
- sparcv9-sun-solaris
- x86_64-apple-darwin
- x86_64-apple-ios
- x86_64-pc-cygwin
- x86_64-pc-solaris
# Fails with:
# `rror calling dlltool 'x86_64-w64-mingw32-dlltool': No such file or
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ impl TcpKeepalive {
target_os = "tvos",
target_os = "watchos",
target_os = "windows",
target_os = "cygwin",
))]
pub const fn with_interval(self, interval: Duration) -> Self {
Self {
Expand Down Expand Up @@ -543,6 +544,7 @@ impl TcpKeepalive {
target_os = "netbsd",
target_os = "tvos",
target_os = "watchos",
target_os = "cygwin",
)
))]
pub const fn with_retries(self, retries: u32) -> Self {
Expand Down
16 changes: 14 additions & 2 deletions src/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ impl Socket {
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
))]
return self._accept4(libc::SOCK_CLOEXEC);

Expand All @@ -284,6 +285,7 @@ impl Socket {
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
)))]
{
let (socket, addr) = self.accept_raw()?;
Expand Down Expand Up @@ -752,6 +754,7 @@ const fn set_common_type(ty: Type) -> Type {
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "cygwin",
))]
let ty = ty._cloexec();

Expand Down Expand Up @@ -781,6 +784,7 @@ fn set_common_flags(socket: Socket) -> io::Result<Socket> {
target_os = "openbsd",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
socket._set_cloexec(true)?;
Expand Down Expand Up @@ -956,7 +960,7 @@ impl Socket {
/// For more information about this option, see [`set_passcred`].
///
/// [`set_passcred`]: Socket::set_passcred
#[cfg(all(unix, target_os = "linux"))]
#[cfg(all(unix, any(target_os = "linux", target_os = "cygwin")))]
pub fn passcred(&self) -> io::Result<bool> {
unsafe {
getsockopt::<c_int>(self.as_raw(), sys::SOL_SOCKET, sys::SO_PASSCRED)
Expand All @@ -968,7 +972,7 @@ impl Socket {
///
/// If this option is enabled, enables the receiving of the `SCM_CREDENTIALS`
/// control messages.
#[cfg(all(unix, target_os = "linux"))]
#[cfg(all(unix, any(target_os = "linux", target_os = "cygwin")))]
pub fn set_passcred(&self, passcred: bool) -> io::Result<()> {
unsafe {
setsockopt(
Expand Down Expand Up @@ -1254,6 +1258,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn join_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1287,6 +1292,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn leave_multicast_v4_n(
&self,
Expand Down Expand Up @@ -1577,6 +1583,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn set_recv_tos_v4(&self, recv_tos: bool) -> io::Result<()> {
unsafe {
Expand Down Expand Up @@ -1608,6 +1615,7 @@ impl Socket {
target_os = "nto",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
)))]
pub fn recv_tos_v4(&self) -> io::Result<bool> {
unsafe {
Expand Down Expand Up @@ -1978,6 +1986,7 @@ impl Socket {
target_os = "hurd",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
pub fn recv_hoplimit_v6(&self) -> io::Result<bool> {
Expand Down Expand Up @@ -2006,6 +2015,7 @@ impl Socket {
target_os = "hurd",
target_os = "espidf",
target_os = "vita",
target_os = "cygwin",
))
))]
pub fn set_recv_hoplimit_v6(&self, recv_hoplimit: bool) -> io::Result<()> {
Expand Down Expand Up @@ -2063,6 +2073,7 @@ impl Socket {
target_os = "netbsd",
target_os = "tvos",
target_os = "watchos",
target_os = "cygwin",
)
))]
pub fn keepalive_interval(&self) -> io::Result<Duration> {
Expand Down Expand Up @@ -2092,6 +2103,7 @@ impl Socket {
target_os = "netbsd",
target_os = "tvos",
target_os = "watchos",
target_os = "cygwin",
)
))]
pub fn keepalive_retries(&self) -> io::Result<u32> {
Expand Down
Loading