Skip to content

Commit 976f235

Browse files
pfmooneyThomasdezeeuw
authored andcommitted
Add support for illumos target
1 parent 4e306ad commit 976f235

File tree

7 files changed

+33
-7
lines changed

7 files changed

+33
-7
lines changed

src/poll.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ use std::{fmt, io};
174174
/// | NetBSD | [kqueue] |
175175
/// | OpenBSD | [kqueue] |
176176
/// | Solaris | [epoll] |
177+
/// | illumos | [epoll] |
177178
/// | Windows | [IOCP] |
178179
/// | iOS | [kqueue] |
179180
/// | macOS | [kqueue] |

src/sys/unix/net.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub(crate) fn new_socket(
2727
target_os = "android",
2828
target_os = "dragonfly",
2929
target_os = "freebsd",
30+
target_os = "illumos",
3031
target_os = "linux",
3132
target_os = "netbsd",
3233
target_os = "openbsd"

src/sys/unix/selector/epoll.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,15 @@ pub struct Selector {
2121

2222
impl Selector {
2323
pub fn new() -> io::Result<Selector> {
24-
// According to libuv `EPOLL_CLOEXEC` is not defined on Android API <
25-
// 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on all platforms,
26-
// so we use that instead.
27-
syscall!(epoll_create1(libc::O_CLOEXEC)).map(|ep| Selector {
24+
// According to libuv, `EPOLL_CLOEXEC` is not defined on Android API <
25+
// 21. But `EPOLL_CLOEXEC` is an alias for `O_CLOEXEC` on that platform,
26+
// so we use it instead.
27+
#[cfg(target_os = "android")]
28+
let flag = libc::O_CLOEXEC;
29+
#[cfg(not(target_os = "android"))]
30+
let flag = libc::EPOLL_CLOEXEC;
31+
32+
syscall!(epoll_create1(flag)).map(|ep| Selector {
2833
#[cfg(debug_assertions)]
2934
id: NEXT_ID.fetch_add(1, Ordering::Relaxed),
3035
ep,
@@ -212,6 +217,7 @@ pub mod event {
212217
}
213218
}
214219

220+
#[cfg(target_os = "android")]
215221
#[test]
216222
fn assert_close_on_exec_flag() {
217223
// This assertion need to be true for Selector::new.

src/sys/unix/selector/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))]
1+
#[cfg(any(
2+
target_os = "android",
3+
target_os = "illumos",
4+
target_os = "linux",
5+
target_os = "solaris"
6+
))]
27
mod epoll;
38

4-
#[cfg(any(target_os = "linux", target_os = "android", target_os = "solaris"))]
9+
#[cfg(any(
10+
target_os = "android",
11+
target_os = "illumos",
12+
target_os = "linux",
13+
target_os = "solaris"
14+
))]
515
pub(crate) use self::epoll::{event, Event, Events, Selector};
616

717
#[cfg(any(

src/sys/unix/tcp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket
6161
target_os = "android",
6262
target_os = "dragonfly",
6363
target_os = "freebsd",
64+
target_os = "illumos",
6465
target_os = "linux",
6566
target_os = "netbsd",
6667
target_os = "openbsd"

src/sys/unix/waker.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ pub use self::kqueue::Waker;
100100

101101
#[cfg(any(
102102
target_os = "dragonfly",
103+
target_os = "illumos",
103104
target_os = "netbsd",
104105
target_os = "openbsd",
105106
target_os = "solaris"
@@ -165,6 +166,7 @@ mod pipe {
165166

166167
#[cfg(any(
167168
target_os = "dragonfly",
169+
target_os = "illumos",
168170
target_os = "netbsd",
169171
target_os = "openbsd",
170172
target_os = "solaris"

tests/tcp_stream.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,12 @@ fn tcp_shutdown_client_read_close_event() {
540540
#[test]
541541
#[cfg_attr(windows, ignore = "fails; client write_closed events are not found")]
542542
#[cfg_attr(
543-
any(target_os = "linux", target_os = "android", target_os = "solaris"),
543+
any(
544+
target_os = "android",
545+
target_os = "illumos",
546+
target_os = "linux",
547+
target_os = "solaris"
548+
),
544549
ignore = "fails; client write_closed events are not found"
545550
)]
546551
fn tcp_shutdown_client_write_close_event() {

0 commit comments

Comments
 (0)