Skip to content

Commit 6870ee6

Browse files
committed
Add OpenBSD compatibility to events
1 parent 607ab97 commit 6870ee6

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

src/sys/event.rs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ pub struct KEvent {
2222
target_os = "dragonfly", target_os = "macos",
2323
target_os = "ios"))]
2424
type type_of_udata = *mut libc::c_void;
25-
#[cfg(any(target_os = "openbsd", target_os = "freebsd",
26-
target_os = "dragonfly", target_os = "macos",
27-
target_os = "ios"))]
25+
#[cfg(any(target_os = "freebsd", target_os = "dragonfly",
26+
target_os = "macos", target_os = "ios"))]
2827
type type_of_data = libc::intptr_t;
2928
#[cfg(any(target_os = "netbsd"))]
3029
type type_of_udata = intptr_t;
31-
#[cfg(any(target_os = "netbsd"))]
30+
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
3231
type type_of_data = libc::int64_t;
3332

3433
#[cfg(not(target_os = "netbsd"))]
@@ -79,16 +78,25 @@ pub enum EventFilter {
7978
}
8079

8180
#[cfg(any(target_os = "macos", target_os = "ios",
82-
target_os = "freebsd", target_os = "dragonfly"))]
81+
target_os = "freebsd", target_os = "dragonfly",
82+
target_os = "openbsd"))]
8383
pub type type_of_event_flag = u16;
84-
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
84+
#[cfg(any(target_os = "netbsd"))]
8585
pub type type_of_event_flag = u32;
8686
libc_bitflags!{
8787
pub flags EventFlag: type_of_event_flag {
8888
EV_ADD,
8989
EV_CLEAR,
9090
EV_DELETE,
9191
EV_DISABLE,
92+
// No released version of OpenBSD supports EV_DISPATCH or EV_RECEIPT.
93+
// These have been commited to the -current branch though and are
94+
// expected to be part of the OpenBSD 6.2 release in Nov 2017.
95+
// See: https://marc.info/?l=openbsd-tech&m=149621427511219&w=2
96+
// https://github.com/rust-lang/libc/pull/613
97+
#[cfg(any(target_os = "macos", target_os = "ios",
98+
target_os = "freebsd", target_os = "dragonfly",
99+
target_os = "netbsd"))]
92100
EV_DISPATCH,
93101
#[cfg(target_os = "freebsd")]
94102
EV_DROP,
@@ -105,7 +113,9 @@ libc_bitflags!{
105113
EV_OOBAND,
106114
#[cfg(any(target_os = "macos", target_os = "ios"))]
107115
EV_POLL,
108-
#[cfg(not(target_os = "openbsd"))]
116+
#[cfg(any(target_os = "macos", target_os = "ios",
117+
target_os = "freebsd", target_os = "dragonfly",
118+
target_os = "netbsd"))]
109119
EV_RECEIPT,
110120
EV_SYSFLAGS,
111121
}
@@ -315,13 +325,13 @@ fn test_struct_kevent() {
315325

316326
let expected = libc::kevent{ident: 0xdeadbeef,
317327
filter: libc::EVFILT_READ,
318-
flags: libc::EV_DISPATCH | libc::EV_ADD,
328+
flags: libc::EV_ONESHOT | libc::EV_ADD,
319329
fflags: libc::NOTE_CHILD | libc::NOTE_EXIT,
320330
data: 0x1337,
321331
udata: udata as type_of_udata};
322332
let actual = KEvent::new(0xdeadbeef,
323333
EventFilter::EVFILT_READ,
324-
EV_DISPATCH | EV_ADD,
334+
EV_ONESHOT | EV_ADD,
325335
NOTE_CHILD | NOTE_EXIT,
326336
0x1337,
327337
udata);

0 commit comments

Comments
 (0)