From f08e7473ac51a024f49e5101fbc5e150fecef2d4 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 28 Nov 2026 22:23:00 +0100 Subject: Fix the generation being lost on 32bit FreeBSD systems, with the udata only 32bits long, it's always zero --- src/ot_event.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/ot_event.c') diff --git a/src/ot_event.c b/src/ot_event.c index 6062f70..cc575f6 100644 --- a/src/ot_event.c +++ b/src/ot_event.c @@ -143,7 +143,7 @@ void event_deinit(void) { back untouched. */ static int event_change(int fd, int what, uint32_t generation, int deleting) { struct kevent change[2], result[2]; - void *udata = (void *)(uintptr_t)(((uint64_t)generation << 32) | (uint32_t)fd); + void *udata = (void *)(uintptr_t)generation; int succeeded = 0, count, i; EV_SET(&change[0], (uintptr_t)fd, EVFILT_READ, @@ -206,11 +206,10 @@ int event_wait(ot_event *out, int max, int timeout_ms) { if ((count = kevent(g_kqueue, NULL, 0, g_ready, max, deadline)) == -1) return errno == EINTR ? 0 : -1; for (i = 0; i < count; ++i) { - uint64_t udata = (uint64_t)(uintptr_t)g_ready[i].udata; - int eof = (g_ready[i].flags & (EV_EOF | EV_ERROR)) != 0; + int eof = (g_ready[i].flags & (EV_EOF | EV_ERROR)) != 0; - out[i].fd = (int)(uint32_t)udata; - out[i].generation = (uint32_t)(udata >> 32); + out[i].fd = (int)g_ready[i].ident; + out[i].generation = (uint32_t)(uintptr_t)g_ready[i].udata; out[i].what = ((g_ready[i].filter == EVFILT_READ || eof) ? EVENT_IN : 0) | ((g_ready[i].filter == EVFILT_WRITE || eof) ? EVENT_OUT : 0); } -- cgit v1.3