Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove cfg attributes for Solaris #1528

Merged
merged 2 commits into from
Nov 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -172,13 +172,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 @@ -382,7 +381,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;
2 changes: 1 addition & 1 deletion tests/aio.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#![cfg(feature = "os-poll")]
#![cfg(any(target_os = "freebsd", target_os = "dragonfly"))]
#![cfg(all(feature = "os-poll", feature = "net"))]

use mio::{event::Source, Events, Interest, Poll, Registry, Token};
use std::{
Expand Down
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
2 changes: 1 addition & 1 deletion tests/unix_pipe.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(all(unix, feature = "os-poll", feature = "os-ext"))]
#![cfg(all(unix, feature = "os-poll", feature = "os-ext", feature = "net"))]

use std::io::{Read, Write};
use std::process::{Command, Stdio};
Expand Down
2 changes: 1 addition & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Not all functions are used by all tests.
#![allow(dead_code, unused_macros)]
#![cfg(any(feature = "os-poll", feature = "net"))]
#![cfg(all(feature = "os-poll", feature = "net"))]

use std::mem::size_of;
use std::net::SocketAddr;
Expand Down
2 changes: 1 addition & 1 deletion tests/waker.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![cfg(feature = "os-poll")]
#![cfg(all(feature = "os-poll", feature = "net"))]

use mio::{Events, Poll, Token, Waker};
use std::sync::{Arc, Barrier};
Expand Down