Skip to content

Commit

Permalink
Add epoll support for Redox (#985)
Browse files Browse the repository at this point in the history
For now it seems that epoll is the preferred way to access Redox's
underlying polling interface. There are event schemes but until Redox's
syscalls are better integrated with Rustix it's probably not worth it
yet.

cc smol-rs/polling#176

Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull authored Jan 16, 2024
1 parent 9e9c4ec commit 916887b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/backend/libc/conv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ pub(super) fn ret_c_int(raw: c::c_int) -> io::Result<c::c_int> {
}
}

#[cfg(linux_kernel)]
#[cfg(any(linux_kernel, all(target_os = "redox", feature = "event")))]
#[inline]
pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> {
if raw == -1 {
Expand Down
24 changes: 17 additions & 7 deletions src/backend/libc/event/epoll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ pub fn add(
as_mut_ptr(&mut Event {
flags: event_flags,
data,
#[cfg(target_os = "redox")]
_pad: 0,
})
.cast(),
))
Expand Down Expand Up @@ -228,6 +230,8 @@ pub fn modify(
as_mut_ptr(&mut Event {
flags: event_flags,
data,
#[cfg(target_os = "redox")]
_pad: 0,
})
.cast(),
))
Expand Down Expand Up @@ -295,13 +299,16 @@ impl<'a> Iterator for Iter<'a> {
/// A record of an event that occurred.
#[repr(C)]
#[cfg_attr(
any(
all(
target_arch = "x86",
not(target_env = "musl"),
not(target_os = "android"),
),
target_arch = "x86_64",
all(
linux_kernel,
any(
all(
target_arch = "x86",
not(target_env = "musl"),
not(target_os = "android"),
),
target_arch = "x86_64",
)
),
repr(packed)
)]
Expand All @@ -311,6 +318,9 @@ pub struct Event {
pub flags: EventFlags,
/// User data.
pub data: EventData,

#[cfg(target_os = "redox")]
_pad: u64,
}

/// Data associated with an [`Event`]. This can either be a 64-bit integer
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(linux_kernel)]
#[cfg(any(linux_kernel, target_os = "redox"))]
pub mod epoll;
2 changes: 1 addition & 1 deletion src/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ mod poll;
#[cfg(solarish)]
pub mod port;

#[cfg(linux_kernel)]
#[cfg(any(linux_kernel, target_os = "redox"))]
pub use crate::backend::event::epoll;
#[cfg(any(
linux_kernel,
Expand Down

0 comments on commit 916887b

Please sign in to comment.