Skip to content

Commit 5e5360a

Browse files
authored
Enable a few features on more platforms. (#1203)
* Enable a few features on more platforms. Define `PollFlags::RDHUP` on FreeBSD, `AT_EACCESS` on Emscripten, and `ptsname` on Illumos. * Enable `epoll` on solarish.
1 parent 5a3dabc commit 5e5360a

File tree

8 files changed

+52
-20
lines changed

8 files changed

+52
-20
lines changed

src/backend/libc/conv.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ pub(super) fn ret_c_int(raw: c::c_int) -> io::Result<c::c_int> {
7070
}
7171
}
7272

73-
#[cfg(any(linux_kernel, all(target_os = "redox", feature = "event")))]
73+
#[cfg(any(
74+
linux_kernel,
75+
all(solarish, feature = "event"),
76+
all(target_os = "redox", feature = "event")
77+
))]
7478
#[inline]
7579
pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> {
7680
if raw == -1 {

src/backend/libc/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ pub(crate) mod types;
55
#[cfg_attr(windows, path = "windows_syscalls.rs")]
66
pub(crate) mod syscalls;
77

8-
#[cfg(any(linux_kernel, target_os = "redox"))]
8+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
99
pub mod epoll;

src/backend/libc/event/poll_fd.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,14 @@ bitflags! {
4040
#[cfg(not(target_os = "espidf"))]
4141
const NVAL = c::POLLNVAL;
4242
/// `POLLRDHUP`
43-
#[cfg(all(
44-
linux_kernel,
45-
not(any(target_arch = "sparc", target_arch = "sparc64"))),
46-
)]
43+
#[cfg(any(
44+
target_os = "freebsd",
45+
target_os = "illumos",
46+
all(
47+
linux_kernel,
48+
not(any(target_arch = "sparc", target_arch = "sparc64"))
49+
),
50+
))]
4751
const RDHUP = c::POLLRDHUP;
4852

4953
/// <https://docs.rs/bitflags/*/bitflags/#externally-defined-flags>

src/backend/libc/event/syscalls.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::backend::c;
55
use crate::backend::conv::ret;
66
use crate::backend::conv::ret_c_int;
77
#[cfg(feature = "alloc")]
8-
#[cfg(any(linux_kernel, target_os = "redox"))]
8+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
99
use crate::backend::conv::ret_u32;
1010
#[cfg(solarish)]
1111
use crate::event::port::Event;
@@ -22,7 +22,7 @@ use crate::event::PollFd;
2222
use crate::io;
2323
#[cfg(solarish)]
2424
use crate::utils::as_mut_ptr;
25-
#[cfg(any(linux_kernel, target_os = "redox"))]
25+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
2626
use crate::utils::as_ptr;
2727
#[cfg(any(
2828
all(feature = "alloc", bsd),
@@ -351,13 +351,13 @@ pub(crate) fn pause() {
351351
}
352352

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

359359
#[inline]
360-
#[cfg(any(linux_kernel, target_os = "redox"))]
360+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
361361
pub(crate) fn epoll_add(
362362
epoll: BorrowedFd<'_>,
363363
source: BorrowedFd<'_>,
@@ -378,7 +378,7 @@ pub(crate) fn epoll_add(
378378
}
379379

380380
#[inline]
381-
#[cfg(any(linux_kernel, target_os = "redox"))]
381+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
382382
pub(crate) fn epoll_mod(
383383
epoll: BorrowedFd<'_>,
384384
source: BorrowedFd<'_>,
@@ -396,7 +396,7 @@ pub(crate) fn epoll_mod(
396396
}
397397

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

411411
#[inline]
412412
#[cfg(feature = "alloc")]
413-
#[cfg(any(linux_kernel, target_os = "redox"))]
413+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
414414
pub(crate) fn epoll_wait(
415415
epoll: BorrowedFd<'_>,
416416
events: &mut [MaybeUninit<crate::event::epoll::Event>],

src/backend/libc/fs/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ bitflags! {
4040
const SYMLINK_NOFOLLOW = bitcast!(c::AT_SYMLINK_NOFOLLOW);
4141

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

4646
/// `AT_REMOVEDIR`

src/backend/libc/pty/syscalls.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,13 @@ use crate::fd::BorrowedFd;
66
use crate::io;
77
#[cfg(all(
88
feature = "alloc",
9-
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
9+
any(
10+
apple,
11+
linux_like,
12+
target_os = "freebsd",
13+
target_os = "fuchsia",
14+
target_os = "illumos"
15+
)
1016
))]
1117
use {
1218
crate::ffi::{CStr, CString},
@@ -26,7 +32,13 @@ pub(crate) fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> {
2632

2733
#[cfg(all(
2834
feature = "alloc",
29-
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
35+
any(
36+
apple,
37+
linux_like,
38+
target_os = "freebsd",
39+
target_os = "fuchsia",
40+
target_os = "illumos"
41+
)
3042
))]
3143
#[inline]
3244
pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CString> {
@@ -38,7 +50,7 @@ pub(crate) fn ptsname(fd: BorrowedFd<'_>, mut buffer: Vec<u8>) -> io::Result<CSt
3850

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

4456
// FreeBSD 12 doesn't have `ptsname_r`.

src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Event operations.
22
3-
#[cfg(any(linux_kernel, target_os = "redox"))]
3+
#[cfg(any(linux_kernel, solarish, target_os = "redox"))]
44
pub mod epoll;
55
#[cfg(any(
66
linux_kernel,

src/pty.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ use crate::fs::OFlags;
1313
use crate::{backend, io};
1414
#[cfg(all(
1515
feature = "alloc",
16-
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
16+
any(
17+
apple,
18+
linux_like,
19+
target_os = "freebsd",
20+
target_os = "fuchsia",
21+
target_os = "illumos"
22+
)
1723
))]
1824
use {crate::ffi::CString, alloc::vec::Vec};
1925

@@ -115,7 +121,13 @@ pub fn openpt(flags: OpenptFlags) -> io::Result<OwnedFd> {
115121
/// [glibc]: https://sourceware.org/glibc/manual/latest/html_node/Allocation.html#index-ptsname
116122
#[cfg(all(
117123
feature = "alloc",
118-
any(apple, linux_like, target_os = "freebsd", target_os = "fuchsia")
124+
any(
125+
apple,
126+
linux_like,
127+
target_os = "freebsd",
128+
target_os = "fuchsia",
129+
target_os = "illumos"
130+
)
119131
))]
120132
#[inline]
121133
#[doc(alias = "ptsname_r")]

0 commit comments

Comments
 (0)