Skip to content

Commit

Permalink
Add Redox support (#1553)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 authored Mar 17, 2022
1 parent 774dac2 commit 7809c4d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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`");

Expand Down
4 changes: 4 additions & 0 deletions src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(|_| ())
Expand All @@ -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(|_| ())
Expand Down
14 changes: 12 additions & 2 deletions src/sys/unix/selector/mod.rs
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions src/sys/unix/uds/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand 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(
Expand Down
2 changes: 2 additions & 0 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -174,5 +175,6 @@ mod pipe {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "redox",
))]
pub use self::pipe::Waker;

0 comments on commit 7809c4d

Please sign in to comment.