Skip to content

Commit

Permalink
Add support for illumos target
Browse files Browse the repository at this point in the history
  • Loading branch information
pfmooney authored and Thomasdezeeuw committed Apr 26, 2020
1 parent 4e306ad commit 976f235
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ use std::{fmt, io};
/// | NetBSD | [kqueue] |
/// | OpenBSD | [kqueue] |
/// | Solaris | [epoll] |
/// | illumos | [epoll] |
/// | Windows | [IOCP] |
/// | iOS | [kqueue] |
/// | macOS | [kqueue] |
Expand Down
1 change: 1 addition & 0 deletions src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub(crate) fn new_socket(
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
Expand Down
14 changes: 10 additions & 4 deletions src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ pub struct Selector {

impl Selector {
pub fn new() -> io::Result<Selector> {
// According to libuv `EPOLL_CLOEXEC` is not defined on Android API <
// 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on all platforms,
// so we use that instead.
syscall!(epoll_create1(libc::O_CLOEXEC)).map(|ep| Selector {
// According to libuv, `EPOLL_CLOEXEC` is not defined on Android API <
// 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on that platform,
// so we use it instead.
#[cfg(target_os = "android")]
let flag = libc::O_CLOEXEC;
#[cfg(not(target_os = "android"))]
let flag = libc::EPOLL_CLOEXEC;

syscall!(epoll_create1(flag)).map(|ep| Selector {
#[cfg(debug_assertions)]
id: NEXT_ID.fetch_add(1, Ordering::Relaxed),
ep,
Expand Down Expand Up @@ -212,6 +217,7 @@ pub mod event {
}
}

#[cfg(target_os = "android")]
#[test]
fn assert_close_on_exec_flag() {
// This assertion need to be true for Selector::new.
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 = "linux", target_os = "android", target_os = "solaris"))]
#[cfg(any(
target_os = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
))]
mod epoll;

#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))]
#[cfg(any(
target_os = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
))]
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 @@ -61,6 +61,7 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
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 @@ -100,6 +100,7 @@ pub use self::kqueue::Waker;

#[cfg(any(
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
Expand Down Expand Up @@ -165,6 +166,7 @@ mod pipe {

#[cfg(any(
target_os = "dragonfly",
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
Expand Down
7 changes: 6 additions & 1 deletion tests/tcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,12 @@ fn tcp_shutdown_client_read_close_event() {
#[test]
#[cfg_attr(windows, ignore = "fails; client write_closed events are not found")]
#[cfg_attr(
any(target_os = "linux", target_os = "android", target_os = "solaris"),
any(
target_os = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
),
ignore = "fails; client write_closed events are not found"
)]
fn tcp_shutdown_client_write_close_event() {
Expand Down

0 comments on commit 976f235

Please sign in to comment.