From 8c50519507e4c9c0b7bd4e9e832fbb6143c4af6b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 5 Nov 2024 12:57:20 -0800 Subject: [PATCH] Disable epoll support on Solaris. (#1208) * Disable epoll support on Solaris. It appears Solaris doesn't support epoll; only Illumos does. And as of rust-lang/libc#3864, the libc crate won't declare the epoll libc interface on Solaris. So disable epoll support on Solaris in rustix too. * Add epoll documentation links for illumos. * Add a documentation reference for ptsname for illumos. * Enable the epoll tests on illumos and redox. * Enable the openpty tests on illumos. --- src/backend/libc/conv.rs | 2 +- src/backend/libc/event/mod.rs | 2 +- src/backend/libc/event/syscalls.rs | 14 +++++++------- src/event/epoll.rs | 10 ++++++++++ src/event/mod.rs | 2 +- src/pty.rs | 2 ++ tests/event/main.rs | 2 +- tests/pty/main.rs | 8 +++++++- 8 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/backend/libc/conv.rs b/src/backend/libc/conv.rs index f4b440b7a..4f7bb5d90 100644 --- a/src/backend/libc/conv.rs +++ b/src/backend/libc/conv.rs @@ -72,7 +72,7 @@ pub(super) fn ret_c_int(raw: c::c_int) -> io::Result { #[cfg(any( linux_kernel, - all(solarish, feature = "event"), + all(target_os = "illumos", feature = "event"), all(target_os = "redox", feature = "event") ))] #[inline] diff --git a/src/backend/libc/event/mod.rs b/src/backend/libc/event/mod.rs index 23797dd78..ff826fc49 100644 --- a/src/backend/libc/event/mod.rs +++ b/src/backend/libc/event/mod.rs @@ -5,5 +5,5 @@ pub(crate) mod types; #[cfg_attr(windows, path = "windows_syscalls.rs")] pub(crate) mod syscalls; -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub mod epoll; diff --git a/src/backend/libc/event/syscalls.rs b/src/backend/libc/event/syscalls.rs index 2f55dfb81..272226faf 100644 --- a/src/backend/libc/event/syscalls.rs +++ b/src/backend/libc/event/syscalls.rs @@ -5,7 +5,7 @@ use crate::backend::c; use crate::backend::conv::ret; use crate::backend::conv::ret_c_int; #[cfg(feature = "alloc")] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] use crate::backend::conv::ret_u32; #[cfg(solarish)] use crate::event::port::Event; @@ -22,7 +22,7 @@ use crate::event::PollFd; use crate::io; #[cfg(solarish)] use crate::utils::as_mut_ptr; -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] use crate::utils::as_ptr; #[cfg(any( all(feature = "alloc", bsd), @@ -351,13 +351,13 @@ pub(crate) fn pause() { } #[inline] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub(crate) fn epoll_create(flags: super::epoll::CreateFlags) -> io::Result { unsafe { ret_owned_fd(c::epoll_create1(bitflags_bits!(flags))) } } #[inline] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub(crate) fn epoll_add( epoll: BorrowedFd<'_>, source: BorrowedFd<'_>, @@ -378,7 +378,7 @@ pub(crate) fn epoll_add( } #[inline] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub(crate) fn epoll_mod( epoll: BorrowedFd<'_>, source: BorrowedFd<'_>, @@ -396,7 +396,7 @@ pub(crate) fn epoll_mod( } #[inline] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Result<()> { unsafe { ret(c::epoll_ctl( @@ -410,7 +410,7 @@ pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Re #[inline] #[cfg(feature = "alloc")] -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub(crate) fn epoll_wait( epoll: BorrowedFd<'_>, events: &mut [MaybeUninit], diff --git a/src/event/epoll.rs b/src/event/epoll.rs index 48aad6c46..b9a9a1bd7 100644 --- a/src/event/epoll.rs +++ b/src/event/epoll.rs @@ -92,8 +92,10 @@ use core::slice; /// /// # References /// - [Linux] +/// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/epoll_create.2.html +/// [illumos]: https://www.illumos.org/man/3C/epoll_create #[inline] #[doc(alias = "epoll_create1")] pub fn create(flags: epoll::CreateFlags) -> io::Result { @@ -114,8 +116,10 @@ pub fn create(flags: epoll::CreateFlags) -> io::Result { /// /// # References /// - [Linux] +/// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html +/// [illumos]: https://www.illumos.org/man/3C/epoll_ctl /// [faq]: https://man7.org/linux/man-pages/man7/epoll.7.html#:~:text=Will%20closing%20a%20file%20descriptor%20cause%20it%20to%20be%20removed%20from%20all%0A%20%20%20%20%20%20%20%20%20%20epoll%20interest%20lists%3F #[doc(alias = "epoll_ctl")] #[inline] @@ -144,8 +148,10 @@ pub fn add( /// /// # References /// - [Linux] +/// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html +/// [illumos]: https://www.illumos.org/man/3C/epoll_ctl #[doc(alias = "epoll_ctl")] #[inline] pub fn modify( @@ -171,8 +177,10 @@ pub fn modify( /// /// # References /// - [Linux] +/// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/epoll_ctl.2.html +/// [illumos]: https://www.illumos.org/man/3C/epoll_ctl #[doc(alias = "epoll_ctl")] #[inline] pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> { @@ -187,8 +195,10 @@ pub fn delete(epoll: impl AsFd, source: impl AsFd) -> io::Result<()> { /// /// # References /// - [Linux] +/// - [illumos] /// /// [Linux]: https://man7.org/linux/man-pages/man2/epoll_wait.2.html +/// [illumos]: https://www.illumos.org/man/3C/epoll_wait #[cfg(feature = "alloc")] #[cfg_attr(docsrs, doc(cfg(feature = "alloc"), alias = "epoll_wait"))] #[inline] diff --git a/src/event/mod.rs b/src/event/mod.rs index 38091a982..13a52ffb6 100644 --- a/src/event/mod.rs +++ b/src/event/mod.rs @@ -1,6 +1,6 @@ //! Event operations. -#[cfg(any(linux_kernel, solarish, target_os = "redox"))] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] pub mod epoll; #[cfg(any( linux_kernel, diff --git a/src/pty.rs b/src/pty.rs index 4bba18d8c..2f887da4d 100644 --- a/src/pty.rs +++ b/src/pty.rs @@ -114,10 +114,12 @@ pub fn openpt(flags: OpenptFlags) -> io::Result { /// # References /// - [POSIX] /// - [Linux] +/// - [illumos] /// - [glibc] /// /// [POSIX]: https://pubs.opengroup.org/onlinepubs/9799919799/functions/ptsname.html /// [Linux]: https://man7.org/linux/man-pages/man3/ptsname.3.html +/// [illumos]: https://www.illumos.org/man/3C/ptsname /// [glibc]: https://sourceware.org/glibc/manual/latest/html_node/Allocation.html#index-ptsname #[cfg(all( feature = "alloc", diff --git a/tests/event/main.rs b/tests/event/main.rs index 5e8ef6936..83a20a1c1 100644 --- a/tests/event/main.rs +++ b/tests/event/main.rs @@ -4,7 +4,7 @@ #[cfg(not(feature = "rustc-dep-of-std"))] // TODO #[cfg(feature = "net")] -#[cfg(linux_kernel)] +#[cfg(any(linux_kernel, target_os = "illumos", target_os = "redox"))] mod epoll; #[cfg(not(windows))] #[cfg(not(target_os = "wasi"))] diff --git a/tests/pty/main.rs b/tests/pty/main.rs index f4872f544..126f9155e 100644 --- a/tests/pty/main.rs +++ b/tests/pty/main.rs @@ -2,5 +2,11 @@ #![cfg(feature = "pty")] -#[cfg(any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia"))] +#[cfg(any( + apple, + linux_like, + target_os = "freebsd", + target_os = "fuchsia", + target_os = "illumos" +))] mod openpty;