Skip to content

Commit 916887b

Browse files
authored
Add epoll support for Redox (#985)
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]>
1 parent 9e9c4ec commit 916887b

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/backend/libc/conv.rs

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

73-
#[cfg(linux_kernel)]
73+
#[cfg(any(linux_kernel, all(target_os = "redox", feature = "event")))]
7474
#[inline]
7575
pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> {
7676
if raw == -1 {

src/backend/libc/event/epoll.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ pub fn add(
197197
as_mut_ptr(&mut Event {
198198
flags: event_flags,
199199
data,
200+
#[cfg(target_os = "redox")]
201+
_pad: 0,
200202
})
201203
.cast(),
202204
))
@@ -228,6 +230,8 @@ pub fn modify(
228230
as_mut_ptr(&mut Event {
229231
flags: event_flags,
230232
data,
233+
#[cfg(target_os = "redox")]
234+
_pad: 0,
231235
})
232236
.cast(),
233237
))
@@ -295,13 +299,16 @@ impl<'a> Iterator for Iter<'a> {
295299
/// A record of an event that occurred.
296300
#[repr(C)]
297301
#[cfg_attr(
298-
any(
299-
all(
300-
target_arch = "x86",
301-
not(target_env = "musl"),
302-
not(target_os = "android"),
303-
),
304-
target_arch = "x86_64",
302+
all(
303+
linux_kernel,
304+
any(
305+
all(
306+
target_arch = "x86",
307+
not(target_env = "musl"),
308+
not(target_os = "android"),
309+
),
310+
target_arch = "x86_64",
311+
)
305312
),
306313
repr(packed)
307314
)]
@@ -311,6 +318,9 @@ pub struct Event {
311318
pub flags: EventFlags,
312319
/// User data.
313320
pub data: EventData,
321+
322+
#[cfg(target_os = "redox")]
323+
_pad: u64,
314324
}
315325

316326
/// Data associated with an [`Event`]. This can either be a 64-bit integer

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(linux_kernel)]
8+
#[cfg(any(linux_kernel, target_os = "redox"))]
99
pub mod epoll;

src/event/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod poll;
1515
#[cfg(solarish)]
1616
pub mod port;
1717

18-
#[cfg(linux_kernel)]
18+
#[cfg(any(linux_kernel, target_os = "redox"))]
1919
pub use crate::backend::event::epoll;
2020
#[cfg(any(
2121
linux_kernel,

0 commit comments

Comments
 (0)