Skip to content
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

Add cygwin support #1410

Merged
merged 2 commits into from
Mar 14, 2025
Merged
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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,4 +269,5 @@ check-cfg = [
'cfg(wasi_ext)',
'cfg(wasip2)',
'cfg(target_arch, values("xtensa"))',
'cfg(target_os, values("cygwin"))',
]
5 changes: 4 additions & 1 deletion src/backend/libc/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ bitflags! {
target_os = "horizon",
target_os = "wasi",
target_os = "vita",
target_os = "cygwin",
solarish
)))]
const ASYNC = bitcast!(c::O_ASYNC);
Expand Down Expand Up @@ -788,6 +789,7 @@ bitflags! {
target_os = "l4re",
target_os = "linux",
target_os = "wasi",
target_os = "cygwin",
)))]
const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE);
/// `FALLOC_FL_COLLAPSE_RANGE`
Expand Down Expand Up @@ -1063,7 +1065,8 @@ pub type StatFs = c::statfs64;
target_os = "nto",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
pub type Fsid = c::fsid_t;

Expand Down
15 changes: 14 additions & 1 deletion src/backend/libc/io/errno.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ impl Errno {
target_os = "redox",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const HWPOISON: Self = Self(c::EHWPOISON);
/// `EIDRM`
Expand Down Expand Up @@ -334,6 +335,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const ISNAM: Self = Self(c::EISNAM);
/// `EKEYEXPIRED`
Expand All @@ -350,6 +352,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const KEYEXPIRED: Self = Self(c::EKEYEXPIRED);
/// `EKEYREJECTED`
Expand All @@ -366,6 +369,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const KEYREJECTED: Self = Self(c::EKEYREJECTED);
/// `EKEYREVOKED`
Expand All @@ -382,6 +386,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const KEYREVOKED: Self = Self(c::EKEYREVOKED);
/// `EL2HLT`
Expand Down Expand Up @@ -534,6 +539,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const MEDIUMTYPE: Self = Self(c::EMEDIUMTYPE);
/// `EMFILE`
Expand Down Expand Up @@ -563,6 +569,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const NAVAIL: Self = Self(c::ENAVAIL);
/// `ENEEDAUTH`
Expand Down Expand Up @@ -643,6 +650,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const NOKEY: Self = Self(c::ENOKEY);
/// `ENOLCK`
Expand Down Expand Up @@ -767,6 +775,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const NOTNAM: Self = Self(c::ENOTNAM);
/// `ENOTRECOVERABLE`
Expand Down Expand Up @@ -895,6 +904,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const REMOTEIO: Self = Self(c::EREMOTEIO);
/// `ERESTART`
Expand All @@ -907,7 +917,8 @@ impl Errno {
target_os = "hurd",
target_os = "l4re",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin",
)))]
pub const RESTART: Self = Self(c::ERESTART);
/// `ERFKILL`
Expand All @@ -926,6 +937,7 @@ impl Errno {
target_os = "redox",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const RFKILL: Self = Self(c::ERFKILL);
/// `EROFS`
Expand Down Expand Up @@ -1024,6 +1036,7 @@ impl Errno {
target_os = "nto",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
pub const UCLEAN: Self = Self(c::EUCLEAN);
/// `EUNATCH`
Expand Down
6 changes: 4 additions & 2 deletions src/backend/libc/io/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ pub(crate) fn writev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>]) -> io::Result<usi
target_os = "nto",
target_os = "redox",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)))]
pub(crate) fn preadv(
fd: BorrowedFd<'_>,
Expand All @@ -127,7 +128,8 @@ pub(crate) fn preadv(
target_os = "horizon",
target_os = "redox",
target_os = "solaris",
target_os = "vita"
target_os = "vita",
target_os = "cygwin",
)))]
pub(crate) fn pwritev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
// Silently cast; we'll get `EINVAL` if the value is negative.
Expand Down
13 changes: 12 additions & 1 deletion src/backend/libc/mm/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const SHARED_VALIDATE = bitcast!(c::MAP_SHARED_VALIDATE);
/// `MAP_PRIVATE`
Expand All @@ -101,6 +102,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const DENYWRITE = bitcast!(c::MAP_DENYWRITE);
/// `MAP_FIXED`
Expand All @@ -117,6 +119,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const FIXED_NOREPLACE = bitcast!(c::MAP_FIXED_NOREPLACE);
/// `MAP_GROWSDOWN`
Expand All @@ -128,6 +131,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const GROWSDOWN = bitcast!(c::MAP_GROWSDOWN);
/// `MAP_HUGETLB`
Expand All @@ -139,6 +143,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const HUGETLB = bitcast!(c::MAP_HUGETLB);
/// `MAP_HUGE_2MB`
Expand All @@ -153,6 +158,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const HUGE_2MB = bitcast!(c::MAP_HUGE_2MB);
/// `MAP_HUGE_1GB`
Expand All @@ -167,6 +173,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const HUGE_1GB = bitcast!(c::MAP_HUGE_1GB);
/// `MAP_LOCKED`
Expand All @@ -178,6 +185,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const LOCKED = bitcast!(c::MAP_LOCKED);
/// `MAP_NOCORE`
Expand All @@ -204,6 +212,7 @@ bitflags! {
target_os = "hurd",
target_os = "nto",
target_os = "redox",
target_os = "cygwin",
)))]
const POPULATE = bitcast!(c::MAP_POPULATE);
/// `MAP_STACK`
Expand All @@ -214,6 +223,7 @@ bitflags! {
target_os = "haiku",
target_os = "hurd",
target_os = "redox",
target_os = "cygwin",
)))]
const STACK = bitcast!(c::MAP_STACK);
/// `MAP_PREFAULT_READ`
Expand All @@ -234,7 +244,8 @@ bitflags! {
all(
linux_kernel,
any(target_arch = "mips", target_arch = "mips32r6", target_arch = "mips64", target_arch = "mips64r6"),
)
),
target_os = "cygwin",
)))]
const SYNC = bitcast!(c::MAP_SYNC);
/// `MAP_UNINITIALIZED`
Expand Down
2 changes: 2 additions & 0 deletions src/backend/libc/net/msghdr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ fn msg_iov_len(len: usize) -> c::c_int {
target_os = "haiku",
target_os = "hurd",
target_os = "nto",
target_os = "cygwin",
))]
#[inline]
fn msg_control_len(len: usize) -> c::socklen_t {
Expand All @@ -84,6 +85,7 @@ fn msg_control_len(len: usize) -> c::socklen_t {
target_os = "redox",
target_os = "vita",
target_os = "wasi",
target_os = "cygwin",
)))]
#[inline]
fn msg_control_len(len: usize) -> c::size_t {
Expand Down
3 changes: 3 additions & 0 deletions src/backend/libc/net/send_recv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ bitflags! {
target_os = "hurd",
target_os = "redox",
target_os = "vita",
target_os = "cygwin",
)))]
const CONFIRM = bitcast!(c::MSG_CONFIRM);
/// `MSG_DONTROUTE`
Expand All @@ -44,6 +45,7 @@ bitflags! {
target_os = "nto",
target_os = "redox",
target_os = "vita",
target_os = "cygwin",
)))]
const MORE = bitcast!(c::MSG_MORE);
#[cfg(not(any(apple, windows, target_os = "redox", target_os = "vita")))]
Expand Down Expand Up @@ -96,6 +98,7 @@ bitflags! {
target_os = "nto",
target_os = "redox",
target_os = "vita",
target_os = "cygwin",
)))]
const ERRQUEUE = bitcast!(c::MSG_ERRQUEUE);
/// `MSG_OOB`
Expand Down
6 changes: 4 additions & 2 deletions src/backend/libc/net/sockopt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use crate::net::xdp::{XdpMmapOffsets, XdpOptionsFlags, XdpRingOffset, XdpStatist
target_os = "netbsd",
target_os = "nto",
target_os = "vita",
target_os = "cygwin",
)))]
use crate::net::AddressFamily;
#[cfg(any(
Expand Down Expand Up @@ -388,6 +389,7 @@ pub(crate) fn socket_send_buffer_size(fd: BorrowedFd<'_>) -> io::Result<usize> {
target_os = "netbsd",
target_os = "nto",
target_os = "vita",
target_os = "cygwin",
)))]
pub(crate) fn socket_domain(fd: BorrowedFd<'_>) -> io::Result<AddressFamily> {
let domain: c::c_int = getsockopt(fd, c::SOL_SOCKET, c::SO_DOMAIN)?;
Expand All @@ -412,13 +414,13 @@ pub(crate) fn socket_oobinline(fd: BorrowedFd<'_>) -> io::Result<bool> {
getsockopt(fd, c::SOL_SOCKET, c::SO_OOBINLINE).map(to_bool)
}

#[cfg(not(any(solarish, windows)))]
#[cfg(not(any(solarish, windows, target_os = "cygwin")))]
#[inline]
pub(crate) fn set_socket_reuseport(fd: BorrowedFd<'_>, value: bool) -> io::Result<()> {
setsockopt(fd, c::SOL_SOCKET, c::SO_REUSEPORT, from_bool(value))
}

#[cfg(not(any(solarish, windows)))]
#[cfg(not(any(solarish, windows, target_os = "cygwin")))]
#[inline]
pub(crate) fn socket_reuseport(fd: BorrowedFd<'_>) -> io::Result<bool> {
getsockopt(fd, c::SOL_SOCKET, c::SO_REUSEPORT).map(to_bool)
Expand Down
18 changes: 12 additions & 6 deletions src/backend/libc/process/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ use crate::process::{Resource, Rlimit};
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
use crate::process::{WaitId, WaitIdOptions, WaitIdStatus};
use core::mem::MaybeUninit;
Expand Down Expand Up @@ -389,7 +390,8 @@ pub(crate) fn _waitpid(
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
#[inline]
pub(crate) fn waitid(id: WaitId<'_>, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
Expand All @@ -411,7 +413,8 @@ pub(crate) fn waitid(id: WaitId<'_>, options: WaitIdOptions) -> io::Result<Optio
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
#[inline]
fn _waitid_all(options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
Expand All @@ -436,7 +439,8 @@ fn _waitid_all(options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
#[inline]
fn _waitid_pid(pid: Pid, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
Expand All @@ -461,7 +465,8 @@ fn _waitid_pid(pid: Pid, options: WaitIdOptions) -> io::Result<Option<WaitIdStat
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
#[inline]
fn _waitid_pgid(pgid: Option<Pid>, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
Expand Down Expand Up @@ -510,7 +515,8 @@ fn _waitid_pidfd(fd: BorrowedFd<'_>, options: WaitIdOptions) -> io::Result<Optio
target_os = "openbsd",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
target_os = "wasi",
target_os = "cygwin"
)))]
#[inline]
unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitIdStatus> {
Expand Down
Loading
Loading