Skip to content

Commit ba9ee75

Browse files
committed
Merge #790
790: Fix netbsd kevent for breakage introduced by libc r=asomers a=Susurrus
2 parents 1b9d205 + 5a7d5b1 commit ba9ee75

File tree

2 files changed

+46
-49
lines changed

2 files changed

+46
-49
lines changed

src/sys/event.rs

Lines changed: 32 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -30,51 +30,40 @@ type type_of_udata = intptr_t;
3030
#[cfg(any(target_os = "netbsd", target_os = "openbsd"))]
3131
type type_of_data = libc::int64_t;
3232

33+
#[cfg(target_os = "netbsd")]
34+
type type_of_event_filter = u32;
3335
#[cfg(not(target_os = "netbsd"))]
3436
type type_of_event_filter = i16;
35-
#[cfg(not(target_os = "netbsd"))]
36-
#[repr(i16)]
37-
#[derive(Clone, Copy, Debug, PartialEq)]
38-
pub enum EventFilter {
39-
EVFILT_AIO = libc::EVFILT_AIO,
40-
#[cfg(target_os = "dragonfly")]
41-
EVFILT_EXCEPT = libc::EVFILT_EXCEPT,
42-
#[cfg(any(target_os = "macos", target_os = "ios",
43-
target_os = "dragonfly",
44-
target_os = "freebsd"))]
45-
EVFILT_FS = libc::EVFILT_FS,
46-
#[cfg(target_os = "freebsd")]
47-
EVFILT_LIO = libc::EVFILT_LIO,
48-
#[cfg(any(target_os = "macos", target_os = "ios"))]
49-
EVFILT_MACHPORT = libc::EVFILT_MACHPORT,
50-
EVFILT_PROC = libc::EVFILT_PROC,
51-
EVFILT_READ = libc::EVFILT_READ,
52-
EVFILT_SIGNAL = libc::EVFILT_SIGNAL,
53-
EVFILT_TIMER = libc::EVFILT_TIMER,
54-
#[cfg(any(target_os = "macos",
55-
target_os = "ios",
56-
target_os = "dragonfly",
57-
target_os = "freebsd"))]
58-
EVFILT_USER = libc::EVFILT_USER,
59-
#[cfg(any(target_os = "macos", target_os = "ios"))]
60-
EVFILT_VM = libc::EVFILT_VM,
61-
EVFILT_VNODE = libc::EVFILT_VNODE,
62-
EVFILT_WRITE = libc::EVFILT_WRITE,
63-
}
64-
65-
#[cfg(target_os = "netbsd")]
66-
type type_of_event_filter = libc::uint32_t;
67-
#[cfg(target_os = "netbsd")]
68-
#[repr(i32)]
69-
#[derive(Clone, Copy, Debug, PartialEq)]
70-
pub enum EventFilter {
71-
EVFILT_READ = libc::EVFILT_READ,
72-
EVFILT_WRITE = libc::EVFILT_WRITE,
73-
EVFILT_AIO = libc::EVFILT_AIO,
74-
EVFILT_VNODE = libc::EVFILT_VNODE,
75-
EVFILT_PROC = libc::EVFILT_PROC,
76-
EVFILT_SIGNAL = libc::EVFILT_SIGNAL,
77-
EVFILT_TIMER = libc::EVFILT_TIMER,
37+
libc_enum!{
38+
#[cfg_attr(target_os = "netbsd", repr(u32))]
39+
#[cfg_attr(not(target_os = "netbsd"), repr(i16))]
40+
pub enum EventFilter {
41+
EVFILT_AIO,
42+
#[cfg(target_os = "dragonfly")]
43+
EVFILT_EXCEPT,
44+
#[cfg(any(target_os = "dragonfly",
45+
target_os = "freebsd",
46+
target_os = "ios",
47+
target_os = "macos"))]
48+
EVFILT_FS,
49+
#[cfg(target_os = "freebsd")]
50+
EVFILT_LIO,
51+
#[cfg(any(target_os = "ios", target_os = "macos"))]
52+
EVFILT_MACHPORT,
53+
EVFILT_PROC,
54+
EVFILT_READ,
55+
EVFILT_SIGNAL,
56+
EVFILT_TIMER,
57+
#[cfg(any(target_os = "dragonfly",
58+
target_os = "freebsd",
59+
target_os = "ios",
60+
target_os = "macos"))]
61+
EVFILT_USER,
62+
#[cfg(any(target_os = "ios", target_os = "macos"))]
63+
EVFILT_VM,
64+
EVFILT_VNODE,
65+
EVFILT_WRITE,
66+
}
7867
}
7968

8069
#[cfg(any(target_os = "dragonfly", target_os = "freebsd",

src/sys/mod.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
#[cfg(any(target_os = "freebsd", target_os = "dragonfly", target_os = "ios",
2-
target_os = "netbsd", target_os = "macos", target_os = "linux"))]
1+
#[cfg(any(target_os = "dragonfly",
2+
target_os = "freebsd",
3+
target_os = "ios",
4+
target_os = "linux",
5+
target_os = "macos",
6+
target_os = "netbsd"))]
37
pub mod aio;
48

5-
#[cfg(any(target_os = "linux", target_os = "android"))]
9+
#[cfg(any(target_os = "android", target_os = "linux"))]
610
pub mod epoll;
711

8-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd",
9-
target_os = "dragonfly", target_os = "openbsd", target_os = "netbsd"))]
12+
#[cfg(any(target_os = "dragonfly",
13+
target_os = "freebsd",
14+
target_os = "ios",
15+
target_os = "macos",
16+
target_os = "netbsd",
17+
target_os = "openbsd"))]
1018
pub mod event;
1119

1220
#[cfg(target_os = "linux")]
@@ -46,7 +54,7 @@ pub mod uio;
4654

4755
pub mod time;
4856

49-
#[cfg(any(target_os = "linux", target_os = "android"))]
57+
#[cfg(any(target_os = "android", target_os = "linux"))]
5058
pub mod ptrace;
5159

5260
pub mod select;

0 commit comments

Comments
 (0)