Skip to content

Commit

Permalink
Port to Fuchsia
Browse files Browse the repository at this point in the history
Once upon a time Mio had support for Fuchsia using Fuchsia specific
code. That code was unmaintained and removed at some point. Since then
Fuchsia added support for (part of) the Posix model, making the port
much easier.

This implementation uses the poll(2) implementation for Poll, and
eventfd(2) for the Waker.
  • Loading branch information
Thomasdezeeuw committed Jun 21, 2024
1 parent 1a738f9 commit e7347b3
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
not(mio_unsupported_force_poll_poll),
not(any(
target_os = "espidf",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hermit",
target_os = "nto",
Expand Down Expand Up @@ -439,6 +440,7 @@ impl Poll {
not(mio_unsupported_force_poll_poll),
not(any(
target_os = "espidf",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hermit",
target_os = "nto",
Expand Down Expand Up @@ -738,6 +740,7 @@ impl fmt::Debug for Registry {
not(any(
target_os = "espidf",
target_os = "haiku",
target_os = "fuchsia",
target_os = "hermit",
target_os = "nto",
target_os = "solaris",
Expand Down
6 changes: 3 additions & 3 deletions src/sys/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ cfg_os_poll! {

cfg_io_source! {
// Both `kqueue` and `epoll` don't need to hold any user space state.
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "fuchsia", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
mod stateless_io_source {
use std::io;
use std::os::fd::RawFd;
Expand Down Expand Up @@ -88,10 +88,10 @@ cfg_os_poll! {
}
}

#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
#[cfg(not(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "fuchsia", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita")))]
pub(crate) use self::stateless_io_source::IoSourceState;

#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita"))]
#[cfg(any(mio_unsupported_force_poll_poll, target_os = "espidf", target_os = "fuchsia", target_os = "haiku", target_os = "hermit", target_os = "nto", target_os = "solaris", target_os = "vita"))]
pub(crate) use self::selector::IoSourceState;
}

Expand Down
2 changes: 2 additions & 0 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
Expand Down Expand Up @@ -62,6 +63,7 @@ pub(crate) fn new_raw() -> io::Result<[RawFd; 2]> {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "haiku",
target_os = "illumos",
target_os = "ios",
Expand Down
3 changes: 3 additions & 0 deletions src/sys/unix/selector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub(crate) use self::epoll::{event, Event, Events, Selector};
#[cfg(any(
mio_unsupported_force_poll_poll,
target_os = "espidf",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hermit",
target_os = "nto",
Expand All @@ -34,6 +35,7 @@ mod poll;
#[cfg(any(
mio_unsupported_force_poll_poll,
target_os = "espidf",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hermit",
target_os = "nto",
Expand All @@ -46,6 +48,7 @@ cfg_io_source! {
#[cfg(any(
mio_unsupported_force_poll_poll,
target_os = "espidf",
target_os = "fuchsia",
target_os = "haiku",
target_os = "hermit",
target_os = "nto",
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 @@ -68,6 +68,7 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
all(not(target_arch="x86"), target_os = "android"),
target_os = "dragonfly",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
Expand Down
11 changes: 9 additions & 2 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ mod fdbased {

#[cfg(all(
not(mio_unsupported_force_waker_pipe),
any(target_os = "linux", target_os = "android"),
any(
target_os = "android",
target_os = "fuchsia",
target_os = "linux",
),
))]
use crate::sys::unix::waker::eventfd::WakerInternal;
#[cfg(any(
Expand Down Expand Up @@ -89,6 +93,7 @@ pub use self::fdbased::Waker;
any(
target_os = "android",
target_os = "espidf",
target_os = "fuchsia",
target_os = "hermit",
target_os = "linux",
)
Expand Down Expand Up @@ -145,7 +150,8 @@ mod eventfd {
#[cfg(any(
mio_unsupported_force_poll_poll,
target_os = "espidf",
target_os = "hermit"
target_os = "fuchsia",
target_os = "hermit",
))]
pub fn ack_and_reset(&self) {
let _ = self.reset();
Expand Down Expand Up @@ -177,6 +183,7 @@ mod eventfd {
any(
mio_unsupported_force_poll_poll,
target_os = "espidf",
target_os = "fuchsia",
target_os = "hermit",
)
))]
Expand Down

0 comments on commit e7347b3

Please sign in to comment.