From c0e5d5daf723a4170d8ec34e70080d5c59b1befe Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 17 Mar 2022 12:14:14 -0600 Subject: [PATCH] Add Redox support --- src/sys/unix/pipe.rs | 2 ++ src/sys/unix/selector/epoll.rs | 4 ++++ src/sys/unix/selector/mod.rs | 14 ++++++++++++-- src/sys/unix/tcp.rs | 1 + src/sys/unix/uds/listener.rs | 2 ++ src/sys/unix/waker.rs | 2 ++ 6 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/sys/unix/pipe.rs b/src/sys/unix/pipe.rs index 3a8a065cc..b2865cda7 100644 --- a/src/sys/unix/pipe.rs +++ b/src/sys/unix/pipe.rs @@ -155,6 +155,7 @@ pub fn new() -> io::Result<(Sender, Receiver)> { target_os = "netbsd", target_os = "openbsd", target_os = "illumos", + target_os = "redox", ))] unsafe { if libc::pipe2(fds.as_mut_ptr(), libc::O_CLOEXEC | libc::O_NONBLOCK) != 0 { @@ -193,6 +194,7 @@ pub fn new() -> io::Result<(Sender, Receiver)> { target_os = "ios", target_os = "macos", target_os = "illumos", + target_os = "redox", )))] compile_error!("unsupported target for `mio::unix::pipe`"); diff --git a/src/sys/unix/selector/epoll.rs b/src/sys/unix/selector/epoll.rs index f4430909b..7853ed654 100644 --- a/src/sys/unix/selector/epoll.rs +++ b/src/sys/unix/selector/epoll.rs @@ -82,6 +82,8 @@ impl Selector { let mut event = libc::epoll_event { events: interests_to_epoll(interests), u64: usize::from(token) as u64, + #[cfg(target_os = "redox")] + _pad: 0, }; syscall!(epoll_ctl(self.ep, libc::EPOLL_CTL_ADD, fd, &mut event)).map(|_| ()) @@ -91,6 +93,8 @@ impl Selector { let mut event = libc::epoll_event { events: interests_to_epoll(interests), u64: usize::from(token) as u64, + #[cfg(target_os = "redox")] + _pad: 0, }; syscall!(epoll_ctl(self.ep, libc::EPOLL_CTL_MOD, fd, &mut event)).map(|_| ()) diff --git a/src/sys/unix/selector/mod.rs b/src/sys/unix/selector/mod.rs index da61e14d7..9ae4c1416 100644 --- a/src/sys/unix/selector/mod.rs +++ b/src/sys/unix/selector/mod.rs @@ -1,7 +1,17 @@ -#[cfg(any(target_os = "android", target_os = "illumos", target_os = "linux"))] +#[cfg(any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "redox", +))] mod epoll; -#[cfg(any(target_os = "android", target_os = "illumos", target_os = "linux"))] +#[cfg(any( + target_os = "android", + target_os = "illumos", + target_os = "linux", + target_os = "redox", +))] pub(crate) use self::epoll::{event, Event, Events, Selector}; #[cfg(any( diff --git a/src/sys/unix/tcp.rs b/src/sys/unix/tcp.rs index 5b02cfcb5..c4d7e9469 100644 --- a/src/sys/unix/tcp.rs +++ b/src/sys/unix/tcp.rs @@ -88,6 +88,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, all(target_arch = "x86", target_os = "android"), target_os = "ios", target_os = "macos", + target_os = "redox" ))] let stream = { syscall!(accept( diff --git a/src/sys/unix/uds/listener.rs b/src/sys/unix/uds/listener.rs index b6218427f..79bd14ee0 100644 --- a/src/sys/unix/uds/listener.rs +++ b/src/sys/unix/uds/listener.rs @@ -42,6 +42,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "ios", target_os = "macos", target_os = "netbsd", + target_os = "redox", // Android x86's seccomp profile forbids calls to `accept4(2)` // See https://github.com/tokio-rs/mio/issues/1445 for details all( @@ -64,6 +65,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So target_os = "ios", target_os = "macos", target_os = "netbsd", + target_os = "redox", all(target_arch = "x86", target_os = "android") ))] let socket = syscall!(accept( diff --git a/src/sys/unix/waker.rs b/src/sys/unix/waker.rs index 684fee981..de88e3181 100644 --- a/src/sys/unix/waker.rs +++ b/src/sys/unix/waker.rs @@ -103,6 +103,7 @@ pub use self::kqueue::Waker; target_os = "illumos", target_os = "netbsd", target_os = "openbsd", + target_os = "redox", ))] mod pipe { use crate::sys::unix::Selector; @@ -174,5 +175,6 @@ mod pipe { target_os = "illumos", target_os = "netbsd", target_os = "openbsd", + target_os = "redox", ))] pub use self::pipe::Waker;