Use consistent cfg attributes

This commit is contained in:
Thomas de Zeeuw
2023-02-13 16:34:22 +01:00
parent 0c24bc2305
commit 512744772f
10 changed files with 45 additions and 52 deletions
+3 -3
View File
@@ -25,7 +25,7 @@ const WRITABLE: u8 = 0b0010;
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
)),
allow(dead_code)
)]
@@ -45,7 +45,7 @@ impl Interest {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
pub const AIO: Interest = Interest(unsafe { NonZeroU8::new_unchecked(AIO) });
@@ -152,7 +152,7 @@ impl fmt::Debug for Interest {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
{
if self.is_aio() {
+5 -5
View File
@@ -20,14 +20,14 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
let socket_type = socket_type | libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;
let socket = syscall!(socket(domain, socket_type, 0))?;
// Mimick `libstd` and set `SO_NOSIGPIPE` on apple systems.
#[cfg(target_vendor = "apple")]
#[cfg(any(target_os = "ios", target_os = "macos"))]
if let Err(err) = syscall!(setsockopt(
socket,
libc::SOL_SOCKET,
@@ -40,7 +40,7 @@ pub(crate) fn new_socket(domain: libc::c_int, socket_type: libc::c_int) -> io::R
}
// Darwin doesn't have SOCK_NONBLOCK or SOCK_CLOEXEC.
#[cfg(target_vendor = "apple")]
#[cfg(any(target_os = "ios", target_os = "macos"))]
{
if let Err(err) = syscall!(fcntl(socket, libc::F_SETFL, libc::O_NONBLOCK)) {
let _ = syscall!(close(socket));
@@ -92,7 +92,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
sin_len: 0,
};
@@ -116,7 +116,7 @@ pub(crate) fn socket_addr(addr: &SocketAddr) -> (SocketAddrCRepr, libc::socklen_
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
sin6_len: 0,
#[cfg(target_os = "illumos")]
+3 -3
View File
@@ -188,12 +188,12 @@ pub fn new() -> io::Result<(Sender, Receiver)> {
target_os = "android",
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "ios",
target_os = "linux",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd",
target_os = "ios",
target_os = "macos",
target_os = "illumos",
target_os = "redox",
)))]
compile_error!("unsupported target for `mio::unix::pipe`");
+16 -17
View File
@@ -21,7 +21,7 @@ type Count = libc::size_t;
// Type of the `filter` field in the `kevent` structure.
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
type Filter = libc::c_short;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
type Filter = i16;
#[cfg(target_os = "netbsd")]
type Filter = u32;
@@ -29,7 +29,7 @@ type Filter = u32;
// Type of the `flags` field in the `kevent` structure.
#[cfg(any(target_os = "dragonfly", target_os = "freebsd", target_os = "openbsd"))]
type Flags = libc::c_ushort;
#[cfg(any(target_os = "macos", target_os = "ios"))]
#[cfg(any(target_os = "ios", target_os = "macos"))]
type Flags = u16;
#[cfg(target_os = "netbsd")]
type Flags = u32;
@@ -405,7 +405,7 @@ pub mod event {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
{
event.filter == libc::EVFILT_AIO
@@ -414,7 +414,7 @@ pub mod event {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
)))]
{
false
@@ -450,7 +450,7 @@ pub mod event {
target_os = "freebsd",
target_os = "dragonfly",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::EVFILT_FS,
#[cfg(target_os = "freebsd")]
@@ -459,7 +459,7 @@ pub mod event {
target_os = "freebsd",
target_os = "dragonfly",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::EVFILT_USER,
#[cfg(target_os = "freebsd")]
@@ -516,49 +516,49 @@ pub mod event {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_TRIGGER,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFNOP,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFAND,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFOR,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFCOPY,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFCTRLMASK,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
libc::NOTE_FFLAGSMASK,
libc::NOTE_LOWAT,
@@ -593,21 +593,21 @@ pub mod event {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
libc::NOTE_TRACK,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
libc::NOTE_TRACKERR,
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
libc::NOTE_CHILD,
#[cfg(any(target_os = "ios", target_os = "macos"))]
@@ -635,7 +635,6 @@ pub mod event {
#[cfg(any(target_os = "freebsd", target_os = "ios", target_os = "macos"))]
libc::NOTE_NSECONDS,
#[cfg(any(target_os = "ios", target_os = "macos"))]
#[cfg(any(target_os = "freebsd", target_os = "ios", target_os = "macos"))]
libc::NOTE_ABSOLUTE,
#[cfg(any(target_os = "ios", target_os = "macos"))]
libc::NOTE_LEEWAY,
+4 -4
View File
@@ -17,20 +17,20 @@ pub(crate) use self::epoll::{event, Event, Events, Selector};
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
))]
mod kqueue;
#[cfg(any(
target_os = "dragonfly",
target_os = "freebsd",
target_os = "netbsd",
target_os = "openbsd",
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "openbsd"
))]
pub(crate) use self::kqueue::{event, Event, Events, Selector};
+4 -7
View File
@@ -60,16 +60,13 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
#[cfg(any(
// Android x86's seccomp profile forbids calls to `accept4(2)`
// See https://github.com/tokio-rs/mio/issues/1445 for details
all(
not(target_arch="x86"),
target_os = "android"
),
all(not(target_arch="x86"), target_os = "android"),
target_os = "dragonfly",
target_os = "freebsd",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd"
target_os = "openbsd",
))]
let stream = {
syscall!(accept4(
@@ -85,10 +82,10 @@ pub(crate) fn accept(listener: &net::TcpListener) -> io::Result<(net::TcpStream,
// OSes inherit the non-blocking flag from the listener, so we just have to
// set `CLOEXEC`.
#[cfg(any(
all(target_arch = "x86", target_os = "android"),
target_os = "ios",
target_os = "macos",
target_os = "redox"
target_os = "redox",
all(target_arch = "x86", target_os = "android"),
))]
let stream = {
syscall!(accept(
+3 -6
View File
@@ -41,10 +41,7 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
target_os = "redox",
// Android x86's seccomp profile forbids calls to `accept4(2)`
// See https://github.com/tokio-rs/mio/issues/1445 for details
all(
target_arch = "x86",
target_os = "android"
)
all(target_arch = "x86", target_os = "android"),
)))]
let socket = {
let flags = libc::SOCK_NONBLOCK | libc::SOCK_CLOEXEC;
@@ -58,10 +55,10 @@ pub(crate) fn accept(listener: &net::UnixListener) -> io::Result<(UnixStream, So
};
#[cfg(any(
target_os = "ios",
target_os = "macos",
target_os = "netbsd",
target_os = "redox",
target_os = "ios",
target_os = "macos",
all(target_arch = "x86", target_os = "android")
))]
let socket = syscall!(accept(
+1 -1
View File
@@ -29,7 +29,7 @@ fn fmt_debug() {
target_os = "dragonfly",
target_os = "freebsd",
target_os = "ios",
target_os = "macos"
target_os = "macos",
))]
{
assert_eq!(format!("{:?}", Interest::AIO), "AIO");
+2 -2
View File
@@ -249,9 +249,9 @@ pub fn set_linger_zero(socket: &TcpStream) {
libc::setsockopt(
socket.as_raw_fd(),
libc::SOL_SOCKET,
#[cfg(target_vendor = "apple")]
#[cfg(any(target_os = "ios", target_os = "macos"))]
libc::SO_LINGER_SEC,
#[cfg(not(target_vendor = "apple"))]
#[cfg(not(any(target_os = "ios", target_os = "macos")))]
libc::SO_LINGER,
&val as *const libc::linger as *const libc::c_void,
size_of::<libc::linger>() as libc::socklen_t,
+4 -4
View File
@@ -260,7 +260,7 @@ fn connect_twice() {
));
t!(poll
.registry()
.register(&mut c1, Token(1), Interest::READABLE | Interest::WRITABLE,));
.register(&mut c1, Token(1), Interest::READABLE | Interest::WRITABLE));
drop(c1);
let mut events = Events::with_capacity(128);
@@ -290,7 +290,7 @@ fn connect_twice() {
let mut c2 = client(&name);
t!(poll
.registry()
.register(&mut c2, Token(2), Interest::READABLE | Interest::WRITABLE,));
.register(&mut c2, Token(2), Interest::READABLE | Interest::WRITABLE));
'outer: loop {
t!(poll.poll(&mut events, None));
@@ -311,7 +311,7 @@ fn reregister_deregister_before_register() {
assert_eq!(
poll.registry()
.reregister(&mut pipe, Token(0), Interest::READABLE,)
.reregister(&mut pipe, Token(0), Interest::READABLE)
.unwrap_err()
.kind(),
io::ErrorKind::NotFound,
@@ -337,7 +337,7 @@ fn reregister_deregister_different_poll() {
assert_eq!(
poll2
.registry()
.reregister(&mut pipe, Token(0), Interest::READABLE,)
.reregister(&mut pipe, Token(0), Interest::READABLE)
.unwrap_err()
.kind(),
io::ErrorKind::AlreadyExists,