Skip to content

Commit f2e1474

Browse files
authored
Add cygwin support (#1410)
1 parent 75ec9ee commit f2e1474

31 files changed

+194
-48
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,5 @@ check-cfg = [
269269
'cfg(wasi_ext)',
270270
'cfg(wasip2)',
271271
'cfg(target_arch, values("xtensa"))',
272+
'cfg(target_os, values("cygwin"))',
272273
]

src/backend/libc/fs/types.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ bitflags! {
381381
target_os = "horizon",
382382
target_os = "wasi",
383383
target_os = "vita",
384+
target_os = "cygwin",
384385
solarish
385386
)))]
386387
const ASYNC = bitcast!(c::O_ASYNC);
@@ -788,6 +789,7 @@ bitflags! {
788789
target_os = "l4re",
789790
target_os = "linux",
790791
target_os = "wasi",
792+
target_os = "cygwin",
791793
)))]
792794
const NO_HIDE_STALE = bitcast!(c::FALLOC_FL_NO_HIDE_STALE);
793795
/// `FALLOC_FL_COLLAPSE_RANGE`
@@ -1063,7 +1065,8 @@ pub type StatFs = c::statfs64;
10631065
target_os = "nto",
10641066
target_os = "redox",
10651067
target_os = "vita",
1066-
target_os = "wasi"
1068+
target_os = "wasi",
1069+
target_os = "cygwin"
10671070
)))]
10681071
pub type Fsid = c::fsid_t;
10691072

src/backend/libc/io/errno.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ impl Errno {
285285
target_os = "redox",
286286
target_os = "vita",
287287
target_os = "wasi",
288+
target_os = "cygwin",
288289
)))]
289290
pub const HWPOISON: Self = Self(c::EHWPOISON);
290291
/// `EIDRM`
@@ -334,6 +335,7 @@ impl Errno {
334335
target_os = "nto",
335336
target_os = "vita",
336337
target_os = "wasi",
338+
target_os = "cygwin",
337339
)))]
338340
pub const ISNAM: Self = Self(c::EISNAM);
339341
/// `EKEYEXPIRED`
@@ -350,6 +352,7 @@ impl Errno {
350352
target_os = "nto",
351353
target_os = "vita",
352354
target_os = "wasi",
355+
target_os = "cygwin",
353356
)))]
354357
pub const KEYEXPIRED: Self = Self(c::EKEYEXPIRED);
355358
/// `EKEYREJECTED`
@@ -366,6 +369,7 @@ impl Errno {
366369
target_os = "nto",
367370
target_os = "vita",
368371
target_os = "wasi",
372+
target_os = "cygwin",
369373
)))]
370374
pub const KEYREJECTED: Self = Self(c::EKEYREJECTED);
371375
/// `EKEYREVOKED`
@@ -382,6 +386,7 @@ impl Errno {
382386
target_os = "nto",
383387
target_os = "vita",
384388
target_os = "wasi",
389+
target_os = "cygwin",
385390
)))]
386391
pub const KEYREVOKED: Self = Self(c::EKEYREVOKED);
387392
/// `EL2HLT`
@@ -534,6 +539,7 @@ impl Errno {
534539
target_os = "nto",
535540
target_os = "vita",
536541
target_os = "wasi",
542+
target_os = "cygwin",
537543
)))]
538544
pub const MEDIUMTYPE: Self = Self(c::EMEDIUMTYPE);
539545
/// `EMFILE`
@@ -563,6 +569,7 @@ impl Errno {
563569
target_os = "nto",
564570
target_os = "vita",
565571
target_os = "wasi",
572+
target_os = "cygwin",
566573
)))]
567574
pub const NAVAIL: Self = Self(c::ENAVAIL);
568575
/// `ENEEDAUTH`
@@ -643,6 +650,7 @@ impl Errno {
643650
target_os = "nto",
644651
target_os = "vita",
645652
target_os = "wasi",
653+
target_os = "cygwin",
646654
)))]
647655
pub const NOKEY: Self = Self(c::ENOKEY);
648656
/// `ENOLCK`
@@ -767,6 +775,7 @@ impl Errno {
767775
target_os = "nto",
768776
target_os = "vita",
769777
target_os = "wasi",
778+
target_os = "cygwin",
770779
)))]
771780
pub const NOTNAM: Self = Self(c::ENOTNAM);
772781
/// `ENOTRECOVERABLE`
@@ -895,6 +904,7 @@ impl Errno {
895904
target_os = "nto",
896905
target_os = "vita",
897906
target_os = "wasi",
907+
target_os = "cygwin",
898908
)))]
899909
pub const REMOTEIO: Self = Self(c::EREMOTEIO);
900910
/// `ERESTART`
@@ -907,7 +917,8 @@ impl Errno {
907917
target_os = "hurd",
908918
target_os = "l4re",
909919
target_os = "vita",
910-
target_os = "wasi"
920+
target_os = "wasi",
921+
target_os = "cygwin",
911922
)))]
912923
pub const RESTART: Self = Self(c::ERESTART);
913924
/// `ERFKILL`
@@ -926,6 +937,7 @@ impl Errno {
926937
target_os = "redox",
927938
target_os = "vita",
928939
target_os = "wasi",
940+
target_os = "cygwin",
929941
)))]
930942
pub const RFKILL: Self = Self(c::ERFKILL);
931943
/// `EROFS`
@@ -1024,6 +1036,7 @@ impl Errno {
10241036
target_os = "nto",
10251037
target_os = "vita",
10261038
target_os = "wasi",
1039+
target_os = "cygwin",
10271040
)))]
10281041
pub const UCLEAN: Self = Self(c::EUCLEAN);
10291042
/// `EUNATCH`

src/backend/libc/io/syscalls.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ pub(crate) fn writev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>]) -> io::Result<usi
101101
target_os = "nto",
102102
target_os = "redox",
103103
target_os = "solaris",
104-
target_os = "vita"
104+
target_os = "vita",
105+
target_os = "cygwin",
105106
)))]
106107
pub(crate) fn preadv(
107108
fd: BorrowedFd<'_>,
@@ -127,7 +128,8 @@ pub(crate) fn preadv(
127128
target_os = "horizon",
128129
target_os = "redox",
129130
target_os = "solaris",
130-
target_os = "vita"
131+
target_os = "vita",
132+
target_os = "cygwin",
131133
)))]
132134
pub(crate) fn pwritev(fd: BorrowedFd<'_>, bufs: &[IoSlice<'_>], offset: u64) -> io::Result<usize> {
133135
// Silently cast; we'll get `EINVAL` if the value is negative.

src/backend/libc/mm/types.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ bitflags! {
8888
target_os = "hurd",
8989
target_os = "nto",
9090
target_os = "redox",
91+
target_os = "cygwin",
9192
)))]
9293
const SHARED_VALIDATE = bitcast!(c::MAP_SHARED_VALIDATE);
9394
/// `MAP_PRIVATE`
@@ -101,6 +102,7 @@ bitflags! {
101102
target_os = "hurd",
102103
target_os = "nto",
103104
target_os = "redox",
105+
target_os = "cygwin",
104106
)))]
105107
const DENYWRITE = bitcast!(c::MAP_DENYWRITE);
106108
/// `MAP_FIXED`
@@ -117,6 +119,7 @@ bitflags! {
117119
target_os = "hurd",
118120
target_os = "nto",
119121
target_os = "redox",
122+
target_os = "cygwin",
120123
)))]
121124
const FIXED_NOREPLACE = bitcast!(c::MAP_FIXED_NOREPLACE);
122125
/// `MAP_GROWSDOWN`
@@ -128,6 +131,7 @@ bitflags! {
128131
target_os = "hurd",
129132
target_os = "nto",
130133
target_os = "redox",
134+
target_os = "cygwin",
131135
)))]
132136
const GROWSDOWN = bitcast!(c::MAP_GROWSDOWN);
133137
/// `MAP_HUGETLB`
@@ -139,6 +143,7 @@ bitflags! {
139143
target_os = "hurd",
140144
target_os = "nto",
141145
target_os = "redox",
146+
target_os = "cygwin",
142147
)))]
143148
const HUGETLB = bitcast!(c::MAP_HUGETLB);
144149
/// `MAP_HUGE_2MB`
@@ -153,6 +158,7 @@ bitflags! {
153158
target_os = "hurd",
154159
target_os = "nto",
155160
target_os = "redox",
161+
target_os = "cygwin",
156162
)))]
157163
const HUGE_2MB = bitcast!(c::MAP_HUGE_2MB);
158164
/// `MAP_HUGE_1GB`
@@ -167,6 +173,7 @@ bitflags! {
167173
target_os = "hurd",
168174
target_os = "nto",
169175
target_os = "redox",
176+
target_os = "cygwin",
170177
)))]
171178
const HUGE_1GB = bitcast!(c::MAP_HUGE_1GB);
172179
/// `MAP_LOCKED`
@@ -178,6 +185,7 @@ bitflags! {
178185
target_os = "hurd",
179186
target_os = "nto",
180187
target_os = "redox",
188+
target_os = "cygwin",
181189
)))]
182190
const LOCKED = bitcast!(c::MAP_LOCKED);
183191
/// `MAP_NOCORE`
@@ -204,6 +212,7 @@ bitflags! {
204212
target_os = "hurd",
205213
target_os = "nto",
206214
target_os = "redox",
215+
target_os = "cygwin",
207216
)))]
208217
const POPULATE = bitcast!(c::MAP_POPULATE);
209218
/// `MAP_STACK`
@@ -214,6 +223,7 @@ bitflags! {
214223
target_os = "haiku",
215224
target_os = "hurd",
216225
target_os = "redox",
226+
target_os = "cygwin",
217227
)))]
218228
const STACK = bitcast!(c::MAP_STACK);
219229
/// `MAP_PREFAULT_READ`
@@ -234,7 +244,8 @@ bitflags! {
234244
all(
235245
linux_kernel,
236246
any(target_arch = "mips", target_arch = "mips32r6", target_arch = "mips64", target_arch = "mips64r6"),
237-
)
247+
),
248+
target_os = "cygwin",
238249
)))]
239250
const SYNC = bitcast!(c::MAP_SYNC);
240251
/// `MAP_UNINITIALIZED`

src/backend/libc/net/msghdr.rs

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ fn msg_iov_len(len: usize) -> c::c_int {
6262
target_os = "haiku",
6363
target_os = "hurd",
6464
target_os = "nto",
65+
target_os = "cygwin",
6566
))]
6667
#[inline]
6768
fn msg_control_len(len: usize) -> c::socklen_t {
@@ -84,6 +85,7 @@ fn msg_control_len(len: usize) -> c::socklen_t {
8485
target_os = "redox",
8586
target_os = "vita",
8687
target_os = "wasi",
88+
target_os = "cygwin",
8789
)))]
8890
#[inline]
8991
fn msg_control_len(len: usize) -> c::size_t {

src/backend/libc/net/send_recv.rs

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ bitflags! {
2323
target_os = "hurd",
2424
target_os = "redox",
2525
target_os = "vita",
26+
target_os = "cygwin",
2627
)))]
2728
const CONFIRM = bitcast!(c::MSG_CONFIRM);
2829
/// `MSG_DONTROUTE`
@@ -44,6 +45,7 @@ bitflags! {
4445
target_os = "nto",
4546
target_os = "redox",
4647
target_os = "vita",
48+
target_os = "cygwin",
4749
)))]
4850
const MORE = bitcast!(c::MSG_MORE);
4951
#[cfg(not(any(apple, windows, target_os = "redox", target_os = "vita")))]
@@ -96,6 +98,7 @@ bitflags! {
9698
target_os = "nto",
9799
target_os = "redox",
98100
target_os = "vita",
101+
target_os = "cygwin",
99102
)))]
100103
const ERRQUEUE = bitcast!(c::MSG_ERRQUEUE);
101104
/// `MSG_OOB`

src/backend/libc/net/sockopt.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use crate::net::xdp::{XdpMmapOffsets, XdpOptionsFlags, XdpRingOffset, XdpStatist
2727
target_os = "netbsd",
2828
target_os = "nto",
2929
target_os = "vita",
30+
target_os = "cygwin",
3031
)))]
3132
use crate::net::AddressFamily;
3233
#[cfg(any(
@@ -388,6 +389,7 @@ pub(crate) fn socket_send_buffer_size(fd: BorrowedFd<'_>) -> io::Result<usize> {
388389
target_os = "netbsd",
389390
target_os = "nto",
390391
target_os = "vita",
392+
target_os = "cygwin",
391393
)))]
392394
pub(crate) fn socket_domain(fd: BorrowedFd<'_>) -> io::Result<AddressFamily> {
393395
let domain: c::c_int = getsockopt(fd, c::SOL_SOCKET, c::SO_DOMAIN)?;
@@ -412,13 +414,13 @@ pub(crate) fn socket_oobinline(fd: BorrowedFd<'_>) -> io::Result<bool> {
412414
getsockopt(fd, c::SOL_SOCKET, c::SO_OOBINLINE).map(to_bool)
413415
}
414416

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

421-
#[cfg(not(any(solarish, windows)))]
423+
#[cfg(not(any(solarish, windows, target_os = "cygwin")))]
422424
#[inline]
423425
pub(crate) fn socket_reuseport(fd: BorrowedFd<'_>) -> io::Result<bool> {
424426
getsockopt(fd, c::SOL_SOCKET, c::SO_REUSEPORT).map(to_bool)

src/backend/libc/process/syscalls.rs

+12-6
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ use crate::process::{Resource, Rlimit};
6969
target_os = "openbsd",
7070
target_os = "redox",
7171
target_os = "vita",
72-
target_os = "wasi"
72+
target_os = "wasi",
73+
target_os = "cygwin"
7374
)))]
7475
use crate::process::{WaitId, WaitIdOptions, WaitIdStatus};
7576
use core::mem::MaybeUninit;
@@ -389,7 +390,8 @@ pub(crate) fn _waitpid(
389390
target_os = "openbsd",
390391
target_os = "redox",
391392
target_os = "vita",
392-
target_os = "wasi"
393+
target_os = "wasi",
394+
target_os = "cygwin"
393395
)))]
394396
#[inline]
395397
pub(crate) fn waitid(id: WaitId<'_>, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
@@ -411,7 +413,8 @@ pub(crate) fn waitid(id: WaitId<'_>, options: WaitIdOptions) -> io::Result<Optio
411413
target_os = "openbsd",
412414
target_os = "redox",
413415
target_os = "vita",
414-
target_os = "wasi"
416+
target_os = "wasi",
417+
target_os = "cygwin"
415418
)))]
416419
#[inline]
417420
fn _waitid_all(options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
@@ -436,7 +439,8 @@ fn _waitid_all(options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
436439
target_os = "openbsd",
437440
target_os = "redox",
438441
target_os = "vita",
439-
target_os = "wasi"
442+
target_os = "wasi",
443+
target_os = "cygwin"
440444
)))]
441445
#[inline]
442446
fn _waitid_pid(pid: Pid, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
@@ -461,7 +465,8 @@ fn _waitid_pid(pid: Pid, options: WaitIdOptions) -> io::Result<Option<WaitIdStat
461465
target_os = "openbsd",
462466
target_os = "redox",
463467
target_os = "vita",
464-
target_os = "wasi"
468+
target_os = "wasi",
469+
target_os = "cygwin"
465470
)))]
466471
#[inline]
467472
fn _waitid_pgid(pgid: Option<Pid>, options: WaitIdOptions) -> io::Result<Option<WaitIdStatus>> {
@@ -510,7 +515,8 @@ fn _waitid_pidfd(fd: BorrowedFd<'_>, options: WaitIdOptions) -> io::Result<Optio
510515
target_os = "openbsd",
511516
target_os = "redox",
512517
target_os = "vita",
513-
target_os = "wasi"
518+
target_os = "wasi",
519+
target_os = "cygwin"
514520
)))]
515521
#[inline]
516522
unsafe fn cvt_waitid_status(status: MaybeUninit<c::siginfo_t>) -> Option<WaitIdStatus> {

0 commit comments

Comments
 (0)