Skip to content

Commit 5947faf

Browse files
committed
Add support for illumos target
1 parent aaa243c commit 5947faf

File tree

8 files changed

+32
-11
lines changed

8 files changed

+32
-11
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ extra-docs = []
3535
log = "0.4.8"
3636

3737
[target.'cfg(unix)'.dependencies]
38-
libc = "0.2.62"
38+
libc = "0.2.69"
3939

4040
[target.'cfg(windows)'.dependencies]
4141
miow = "0.3.3"

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 = "linux")]
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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ pub fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream, Socket
6262
target_os = "dragonfly",
6363
target_os = "freebsd",
6464
target_os = "linux",
65-
target_os = "openbsd"
65+
target_os = "openbsd",
66+
target_os = "illumos"
6667
))]
6768
let stream = {
6869
syscall!(accept4(

src/sys/unix/waker.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ pub use self::kqueue::Waker;
102102
target_os = "dragonfly",
103103
target_os = "netbsd",
104104
target_os = "openbsd",
105-
target_os = "solaris"
105+
target_os = "solaris",
106+
target_os = "illumos"
106107
))]
107108
mod pipe {
108109
use crate::sys::unix::Selector;
@@ -167,6 +168,7 @@ mod pipe {
167168
target_os = "dragonfly",
168169
target_os = "netbsd",
169170
target_os = "openbsd",
170-
target_os = "solaris"
171+
target_os = "solaris",
172+
target_os = "illumos"
171173
))]
172174
pub use self::pipe::Waker;

tests/tcp_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ 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(target_os = "linux", target_os = "android", target_os = "solaris", target_os = "illumos"),
544544
ignore = "fails; client write_closed events are not found"
545545
)]
546546
fn tcp_shutdown_client_write_close_event() {

0 commit comments

Comments
 (0)