event/
raw.rs

1#[derive(Clone, Copy, Debug, Default)]
2#[repr(C)]
3pub struct RawEventV1 {
4    // NOTE: This field will likely be removed soon (v2), as user_data can already uniquely
5    // identify the origin of any event.
6    pub fd: usize,
7
8    pub user_data: usize,
9    pub flags: u32,
10}
11
12bitflags::bitflags! {
13    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
14    pub struct EventQueueCreateFlagsV1: usize {
15        const NONE = 0;
16    }
17    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
18    pub struct EventQueueGetEventsFlagsV1: usize {
19        const NONE = 0;
20        // TODO: const NONBLOCK = 1;
21        // TODO? const RESTART = 2;
22    }
23}
24type RawResult = usize;
25extern "C" {
26    pub fn redox_event_queue_create_v1(flags: u32) -> RawResult;
27
28    pub fn redox_event_queue_get_events_v1(
29        queue: usize,
30        buf: *mut RawEventV1,
31        buf_count: usize,
32        flags: u32,
33        timeout: *const libredox::data::TimeSpec,
34        sigset: *const libredox::data::SigSet,
35    ) -> RawResult;
36    pub fn redox_event_queue_ctl_v1(
37        queue: usize,
38        fd: usize,
39        flags: u32,
40        user_data: usize,
41    ) -> RawResult;
42
43    // An event queue is currently simply a file descriptor. It would need some new flag to be
44    // allowed not to be one, but keep it opaque anyway, as this will be called from a library.
45    pub fn redox_event_queue_destroy_v1(queue: usize) -> RawResult;
46}
47bitflags::bitflags! {
48    #[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
49    pub struct EventFlags: u32 {
50        const READ = 1;
51        const WRITE = 2;
52    }
53}