Skip to content

Commit 169c1e4

Browse files
committed
Auto merge of #463 - asomers:kevent, r=fiveop
Change KEvent to treat udata as an intptr_t instead of a uintptr_t. This matches NetBSD's C definitions. Other operating systems define it as void*, despite not really being a pointer, but none actually define it as uintptr_t. Better to be right on NetBSD and wrong everywhere else than wrong everywhere. Plus, it's what mio expects. Please include this PR in nix 0.8.0
2 parents dcc4818 + 7e96529 commit 169c1e4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

CHANGELOG.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3030
([#445](https://github.com/nix-rust/nix/pull/410))
3131
- The minimum supported version of rustc is now 1.7.0.
3232
([#444](https://github.com/nix-rust/nix/pull/444))
33-
- Implement `Send` for `KEvent`
34-
([#442](https://github.com/nix-rust/nix/pull/442))
3533
- Changed `KEvent` to an opaque structure that may only be modified by its
3634
constructor and the `ev_set` method.
3735
([#415](https://github.com/nix-rust/nix/pull/415))
36+
([#442](https://github.com/nix-rust/nix/pull/442))
37+
([#463](https://github.com/nix-rust/nix/pull/463))
3838
- `pipe2` now calls `libc::pipe2` where available. Previously it was emulated
3939
using `pipe`, which meant that setting `O_CLOEXEC` was not atomic.
4040
([#427](https://github.com/nix-rust/nix/pull/427))

src/sys/event.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ pub fn kqueue() -> Result<RawFd> {
193193

194194

195195
// KEvent can't derive Send because on some operating systems, udata is defined
196-
// as a void*. However, KEvent's public API always treats udata as a uintptr_t,
196+
// as a void*. However, KEvent's public API always treats udata as an intptr_t,
197197
// which is safe to Send.
198198
unsafe impl Send for KEvent {
199199
}
200200

201201
impl KEvent {
202202
pub fn new(ident: uintptr_t, filter: EventFilter, flags: EventFlag,
203-
fflags:FilterFlag, data: intptr_t, udata: uintptr_t) -> KEvent {
203+
fflags:FilterFlag, data: intptr_t, udata: intptr_t) -> KEvent {
204204
KEvent { kevent: libc::kevent {
205205
ident: ident,
206206
filter: filter as type_of_event_filter,
@@ -231,8 +231,8 @@ impl KEvent {
231231
self.kevent.data
232232
}
233233

234-
pub fn udata(&self) -> uintptr_t {
235-
self.kevent.udata as uintptr_t
234+
pub fn udata(&self) -> intptr_t {
235+
self.kevent.udata as intptr_t
236236
}
237237
}
238238

@@ -282,7 +282,7 @@ pub fn ev_set(ev: &mut KEvent,
282282
filter: EventFilter,
283283
flags: EventFlag,
284284
fflags: FilterFlag,
285-
udata: uintptr_t) {
285+
udata: intptr_t) {
286286

287287
ev.kevent.ident = ident as uintptr_t;
288288
ev.kevent.filter = filter as type_of_event_filter;
@@ -294,7 +294,7 @@ pub fn ev_set(ev: &mut KEvent,
294294

295295
#[test]
296296
fn test_struct_kevent() {
297-
let udata : uintptr_t = 12345;
297+
let udata : intptr_t = 12345;
298298

299299
let expected = libc::kevent{ident: 0xdeadbeef,
300300
filter: libc::EVFILT_READ,

0 commit comments

Comments
 (0)