From 8ab61e3d9a53ea15824c94eb119a035c4505f834 Mon Sep 17 00:00:00 2001 From: Jeremy Soller <jackpot51@gmail.com> Date: Mon, 6 May 2024 15:16:31 -0600 Subject: [PATCH] Convert syscall events to EPOLL events --- src/platform/redox/epoll.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/platform/redox/epoll.rs b/src/platform/redox/epoll.rs index fd7e492c..7420a10c 100644 --- a/src/platform/redox/epoll.rs +++ b/src/platform/redox/epoll.rs @@ -34,6 +34,20 @@ fn epoll_to_event_flags(epoll: c_uint) -> syscall::EventFlags { event_flags } +fn event_flags_to_epoll(flags: syscall::EventFlags) -> c_uint { + let mut epoll = 0; + + if flags.contains(syscall::EventFlags::EVENT_READ) { + epoll |= EPOLLIN; + } + + if flags.contains(syscall::EventFlags::EVENT_WRITE) { + epoll |= EPOLLOUT; + } + + epoll +} + impl PalEpoll for Sys { fn epoll_create1(flags: c_int) -> c_int { Sys::open(c_str!("event:"), O_RDWR | flags, 0) @@ -153,7 +167,7 @@ impl PalEpoll for Sys { } } *target_ptr = epoll_event { - events: event.flags.bits() as _, + events: event_flags_to_epoll(event.flags), data: epoll_data { u64: event.data as u64, }, -- GitLab