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

Enable a few features on more platforms. #1203

Merged
merged 2 commits into from
Nov 4, 2024
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
6 changes: 5 additions & 1 deletion src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,11 @@ pub(super) fn ret_c_int(raw: c::c_int) -> io::Result<c::c_int> {
}
}

#[cfg(any(linux_kernel, all(target_os = "redox", feature = "event")))]
#[cfg(any(
linux_kernel,
all(solarish, feature = "event"),
all(target_os = "redox", feature = "event")
))]
#[inline]
pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> {
if raw == -1 {
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ pub(crate) mod types;
#[cfg_attr(windows, path = "windows_syscalls.rs")]
pub(crate) mod syscalls;

#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epoll is supported in illumos, but is it also supported in solaris? (I could not find the man page.)
https://illumos.org/man/7/epoll

Also, libc defines epoll-related stuff for solarish only in illumos.rs, so doesn't this actually cause a compile error in solaris?
https://github.com/search?q=repo%3Arust-lang%2Flibc+%2Fepoll_%2F+path%3Asrc%2Funix%2Fsolarish&type=code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does compile with the current libc crate. It appears the code you linked to here is only one day old and has not made it to a release yet. I've now filed #1208 to disable epoll support on Solaris in rustix.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link and PR. The comment in in src/unix/solarish/mod.rs removed in the libc PR says:

    // The epoll functions are actually only present on illumos.  However,
    // there are things using epoll on illumos (built using the
    // x86_64-pc-solaris target) which would break until the illumos target is
    // present in rustc.

It appears to be what was used before illumos was added as its own target.

pub mod epoll;
12 changes: 8 additions & 4 deletions src/backend/libc/event/poll_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,14 @@ bitflags! {
#[cfg(not(target_os = "espidf"))]
const NVAL = c::POLLNVAL;
/// `POLLRDHUP`
#[cfg(all(
linux_kernel,
not(any(target_arch = "sparc", target_arch = "sparc64"))),
)]
#[cfg(any(
target_os = "freebsd",
target_os = "illumos",
all(
linux_kernel,
not(any(target_arch = "sparc", target_arch = "sparc64"))
),
))]
const RDHUP = c::POLLRDHUP;

/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>
Expand Down
14 changes: 7 additions & 7 deletions src/backend/libc/event/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
use crate::backend::conv::ret_u32;
#[cfg(solarish)]
use crate::event::port::Event;
Expand All @@ -22,7 +22,7 @@ use crate::event::PollFd;
use crate::io;
#[cfg(solarish)]
use crate::utils::as_mut_ptr;
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
use crate::utils::as_ptr;
#[cfg(any(
all(feature = "alloc", bsd),
Expand Down Expand Up @@ -351,13 +351,13 @@ pub(crate) fn pause() {
}

#[inline]
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub(crate) fn epoll_create(flags: super::epoll::CreateFlags) -> io::Result<OwnedFd> {
unsafe { ret_owned_fd(c::epoll_create1(bitflags_bits!(flags))) }
}

#[inline]
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub(crate) fn epoll_add(
epoll: BorrowedFd<'_>,
source: BorrowedFd<'_>,
Expand All @@ -378,7 +378,7 @@ pub(crate) fn epoll_add(
}

#[inline]
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub(crate) fn epoll_mod(
epoll: BorrowedFd<'_>,
source: BorrowedFd<'_>,
Expand All @@ -396,7 +396,7 @@ pub(crate) fn epoll_mod(
}

#[inline]
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Result<()> {
unsafe {
ret(c::epoll_ctl(
Expand All @@ -410,7 +410,7 @@ pub(crate) fn epoll_del(epoll: BorrowedFd<'_>, source: BorrowedFd<'_>) -> io::Re

#[inline]
#[cfg(feature = "alloc")]
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub(crate) fn epoll_wait(
epoll: BorrowedFd<'_>,
events: &mut [MaybeUninit<crate::event::epoll::Event>],
Expand Down
2 changes: 1 addition & 1 deletion src/backend/libc/fs/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ bitflags! {
const SYMLINK_NOFOLLOW = bitcast!(c::AT_SYMLINK_NOFOLLOW);

/// `AT_EACCESS`
#[cfg(not(any(target_os = "emscripten", target_os = "android")))]
#[cfg(not(target_os = "android"))]
const EACCESS = bitcast!(c::AT_EACCESS);

/// `AT_REMOVEDIR`
Expand Down
18 changes: 15 additions & 3 deletions src/backend/libc/pty/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ use crate::fd::BorrowedFd;
use crate::io;
#[cfg(all(
feature = "alloc",
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
any(
apple,
linux_like,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos"
)
))]
use {
crate::ffi::{CStr, CString},
Expand All @@ -26,7 +32,13 @@ pub(crate) fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> {

#[cfg(all(
feature = "alloc",
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
any(
apple,
linux_like,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos"
)
))]
#[inline]
pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CString> {
Expand All @@ -38,7 +50,7 @@ pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CSt

loop {
// On platforms with `ptsname_r`, use it.
#[cfg(any(linux_like, target_os = "fuchsia"))]
#[cfg(any(linux_like, target_os = "fuchsia", target_os = "illumos"))]
let r = unsafe { c::ptsname_r(borrowed_fd(fd), buffer.as_mut_ptr().cast(), buffer.len()) };

// FreeBSD 12 doesn't have `ptsname_r`.
Expand Down
2 changes: 1 addition & 1 deletion src/event/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Event operations.
#[cfg(any(linux_kernel, target_os = "redox"))]
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
pub mod epoll;
#[cfg(any(
linux_kernel,
Expand Down
16 changes: 14 additions & 2 deletions src/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ use crate::fs::OFlags;
use crate::{backend, io};
#[cfg(all(
feature = "alloc",
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
any(
apple,
linux_like,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos"
)
))]
use {crate::ffi::CString, alloc::vec::Vec};

Expand Down Expand Up @@ -115,7 +121,13 @@ pub fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> {
/// [glibc]: https://sourceware.org/glibc/manual/latest/html_node/Allocation.html#index-ptsname
#[cfg(all(
feature = "alloc",
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
any(
apple,
linux_like,
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos"
)
))]
#[inline]
#[doc(alias = "ptsname_r")]
Expand Down
Loading