Skip to content

Commit

Permalink
Remove cfg attributes for Solaris
Browse files Browse the repository at this point in the history
We never really supported Solaris, we pretended it implemented epoll,
but it never did see #1152. As no
one ever committed to being a maintainer for the port I'm removing it
now with this commit.

Instead replace it with illumuos on the CI, which we do support (as it
supports epoll) and for which we do have maintainers.
  • Loading branch information
Thomasdezeeuw committed Nov 7, 2021
1 parent 7d86108 commit b9f089b
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 41 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ targets = [
"aarch64-linux-android",
"x86_64-apple-darwin",
"x86_64-pc-windows-msvc",
"x86_64-pc-solaris",
"x86_64-unknown-dragonfly",
"x86_64-unknown-freebsd",
"x86_64-unknown-illumos",
"x86_64-unknown-linux-gnu",
"x86_64-unknown-netbsd",
"x86_64-unknown-openbsd",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Targets available via Rustup that are supported.
TARGETS ?= "aarch64-apple-ios" "aarch64-linux-android" "x86_64-apple-darwin" "x86_64-pc-windows-msvc" "x86_64-pc-solaris" "x86_64-unknown-freebsd" "x86_64-unknown-linux-gnu" "x86_64-unknown-netbsd"
TARGETS ?= "aarch64-apple-ios" "aarch64-linux-android" "x86_64-apple-darwin" "x86_64-pc-windows-msvc" "x86_64-unknown-freebsd" "x86_64-unknown-illumos" "x86_64-unknown-linux-gnu" "x86_64-unknown-netbsd"

test:
cargo test --all-features
Expand Down
4 changes: 2 additions & 2 deletions ci/azure-cross-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
vmImage: ubuntu-18.04
target: x86_64-unknown-netbsd

Solaris:
illumos:
vmImage: ubuntu-18.04
target: x86_64-pc-solaris
target: x86_64-unknown-illumos

pool:
vmImage: $(vmImage)
Expand Down
7 changes: 3 additions & 4 deletions src/poll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,12 @@ use std::{fmt, io};
/// | Android | [epoll] |
/// | DragonFly BSD | [kqueue] |
/// | FreeBSD | [kqueue] |
/// | iOS | [kqueue] |
/// | illumos | [epoll] |
/// | Linux | [epoll] |
/// | NetBSD | [kqueue] |
/// | OpenBSD | [kqueue] |
/// | Solaris | [epoll] |
/// | illumos | [epoll] |
/// | Windows | [IOCP] |
/// | iOS | [kqueue] |
/// | macOS | [kqueue] |
///
/// On all supported platforms, socket operations are handled by using the
Expand Down Expand Up @@ -406,7 +405,7 @@ impl Registry {
///
/// # Arguments
///
/// `source: &S: event::Source`: This is the source of events that the
/// `source: &mut S: event::Source`: This is the source of events that the
/// `Poll` instance should monitor for readiness state changes.
///
/// `token: Token`: The caller picks a token to associate with the socket.
Expand Down
7 changes: 3 additions & 4 deletions src/sys/unix/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
.map(|_| socket)
});

// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC. Not sure about
// Solaris, couldn't find anything online.
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "solaris"))]
// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC.
#[cfg(any(target_os = "ios", target_os = "macos"))]
let socket = socket.and_then(|socket| {
// For platforms that don't support flags in socket, we need to
// set the flags ourselves.
Expand Down Expand Up @@ -124,7 +123,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "openbsd"
))]
sin6_len: 0,
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
#[cfg(target_os = "illumos")]
__sin6_src_id: 0,
};

Expand Down
3 changes: 1 addition & 2 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
}
}

#[cfg(any(target_os = "ios", target_os = "macos", target_os = "solaris"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
unsafe {
// For platforms that don't have `pipe2(2)` we need to manually set the
// correct flags on the file descriptor.
Expand Down Expand Up @@ -192,7 +192,6 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
target_os = "openbsd",
target_os = "ios",
target_os = "macos",
target_os = "solaris",
target_os = "illumos",
)))]
compile_error!("unsupported target for `mio::unix::pipe`");
Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/selector/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub mod event {
libc::EPOLLET,
libc::EPOLLRDHUP,
libc::EPOLLONESHOT,
#[cfg(any(target_os = "linux", target_os = "solaris"))]
#[cfg(target_os = "linux")]
libc::EPOLLEXCLUSIVE,
#[cfg(any(target_os = "android", target_os = "linux"))]
libc::EPOLLWAKEUP,
Expand Down
14 changes: 2 additions & 12 deletions src/sys/unix/selector/mod.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
#[cfg(any(
target_os = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
))]
#[cfg(any(target_os = "android", target_os = "illumos", target_os = "linux"))]
mod epoll;

#[cfg(any(
target_os = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
))]
#[cfg(any(target_os = "android", target_os = "illumos", target_os = "linux"))]
pub(crate) use self::epoll::{event, Event, Events, Selector};

#[cfg(any(
Expand Down
1 change: 0 additions & 1 deletion src/sys/unix/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ 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 = "solaris"
))]
let stream = {
syscall!(accept(
Expand Down
2 changes: 0 additions & 2 deletions src/sys/unix/uds/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "solaris",
// Android x86's seccomp profile forbids calls to `accept4(2)`
// See https://github.com/tokio-rs/mio/issues/1445 for details
all(
Expand All @@ -65,7 +64,6 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "solaris",
all(target_arch = "x86", target_os = "android")
))]
let socket = syscall!(accept(
Expand Down
6 changes: 3 additions & 3 deletions src/sys/unix/uds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ cfg_os_poll! {
fn pair<T>(flags: libc::c_int) -> io::Result<(T, T)>
where T: FromRawFd,
{
#[cfg(not(any(target_os = "ios", target_os = "macos", target_os = "solaris")))]
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
let flags = flags | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;

let mut fds = [-1; 2];
syscall!(socketpair(libc::AF_UNIX, flags, 0, fds.as_mut_ptr()))?;
let pair = unsafe { (T::from_raw_fd(fds[0]), T::from_raw_fd(fds[1])) };

// Darwin and Solaris do not have SOCK_NONBLOCK or SOCK_CLOEXEC.
// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC.
//
// In order to set those flags, additional `fcntl` sys calls must be
// performed. If a `fnctl` fails after the sockets have been created,
// the file descriptors will leak. Creating `pair` above ensures that if
// there is an error, the file descriptors are closed.
#[cfg(any(target_os = "ios", target_os = "macos", target_os = "solaris"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
{
syscall!(fcntl(fds[0], libc::F_SETFL, libc::O_NONBLOCK))?;
syscall!(fcntl(fds[0], libc::F_SETFD, libc::FD_CLOEXEC))?;
Expand Down
2 changes: 0 additions & 2 deletions src/sys/unix/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ pub use self::kqueue::Waker;
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
))]
mod pipe {
use crate::sys::unix::Selector;
Expand Down Expand Up @@ -175,6 +174,5 @@ mod pipe {
target_os = "illumos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris"
))]
pub use self::pipe::Waker;
7 changes: 1 addition & 6 deletions tests/tcp_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,7 @@ 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 = "android",
target_os = "illumos",
target_os = "linux",
target_os = "solaris"
),
any(target_os = "android", target_os = "illumos", target_os = "linux"),
ignore = "fails; client write_closed events are not found"
)]
fn tcp_shutdown_client_write_close_event() {
Expand Down

0 comments on commit b9f089b

Please sign in to comment.