Skip to content

Light cleanup of the kevent backend. #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/event/event_kevent.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ _evfiltstr(short filt)
_evfilt2(EVFILT_MACHPORT);
_evfilt2(DISPATCH_EVFILT_MACH_NOTIFICATION);
#endif
#ifdef EVFILT_FS
_evfilt2(EVFILT_FS);
#endif
_evfilt2(EVFILT_USER);
#ifdef EVFILT_SOCK
_evfilt2(EVFILT_SOCK);
Expand Down Expand Up @@ -388,16 +390,18 @@ _dispatch_kevent_print_error(dispatch_kevent_t ke)
switch (ke->data) {
case 0:
return;
#if DISPATCH_USE_KEVENT_QOS
case ERANGE: /* A broken QoS was passed to kevent_id() */
DISPATCH_INTERNAL_CRASH(ke->qos, "Invalid kevent priority");
#endif
default:
// log the unexpected error
_dispatch_bug_kevent_client("kevent", _evfiltstr(ke->filter),
!ke->udata ? NULL :
ke->flags & EV_DELETE ? "delete" :
ke->flags & EV_ADD ? "add" :
ke->flags & EV_ENABLE ? "enable" : "monitor",
(int)ke->data, ke->ident, ke->udata, du);
(int)ke->data, ke->ident, (uint64_t)ke->udata, du);
}
}

Expand Down Expand Up @@ -591,7 +595,6 @@ _dispatch_kq_create(intptr_t *fd_ptr)
guardid_t guard = (uintptr_t)fd_ptr;
kqfd = guarded_kqueue_np(&guard, GUARD_CLOSE | GUARD_DUP);
#else
(void)guard_ptr;
kqfd = kqueue();
#endif
if (kqfd == -1) {
Expand Down Expand Up @@ -860,7 +863,6 @@ _dispatch_kq_unote_set_kevent(dispatch_unote_t _du, dispatch_kevent_t dk,
du->du_priority),
#endif
};
(void)pp; // if DISPATCH_USE_KEVENT_QOS == 0
}

DISPATCH_ALWAYS_INLINE
Expand Down Expand Up @@ -985,6 +987,7 @@ _dispatch_sync_ipc_handoff_end(dispatch_wlh_t wlh, mach_port_t port)
}
#endif

#if DISPATCH_HAVE_DIRECT_KNOTES
DISPATCH_NOINLINE
static bool
_dispatch_kq_unote_update(dispatch_wlh_t wlh, dispatch_unote_t _du,
Expand Down Expand Up @@ -1055,6 +1058,7 @@ _dispatch_kq_unote_update(dispatch_wlh_t wlh, dispatch_unote_t _du,
dispatch_assume_zero(r);
return true;
}
#endif

#pragma mark dispatch_muxnote_t

Expand Down Expand Up @@ -1283,6 +1287,7 @@ _dispatch_unote_unregister_direct(dispatch_unote_t du, uint32_t flags)
#pragma mark -
#pragma mark dispatch_event_loop

#if DISPATCH_USE_KEVENT_WORKLOOP
enum {
DISPATCH_WORKLOOP_ASYNC,
DISPATCH_WORKLOOP_ASYNC_FROM_SYNC,
Expand Down Expand Up @@ -1316,6 +1321,7 @@ static char const * const _dispatch_workloop_actions[] = {
[DISPATCH_WORKLOOP_SYNC_WAKE] = "sync-wake",
[DISPATCH_WORKLOOP_SYNC_END] = "sync-end",
};
#endif

void
_dispatch_event_loop_atfork_child(void)
Expand Down Expand Up @@ -2445,6 +2451,7 @@ const dispatch_source_type_s _dispatch_source_type_vnode = {
.dst_merge_evt = _dispatch_source_merge_evt,
};

#ifdef EVFILT_FS
const dispatch_source_type_s _dispatch_source_type_vfs = {
.dst_kind = "vfs",
.dst_filter = EVFILT_FS,
Expand Down Expand Up @@ -2477,6 +2484,7 @@ const dispatch_source_type_s _dispatch_source_type_vfs = {
.dst_create = _dispatch_unote_create_without_handle,
.dst_merge_evt = _dispatch_source_merge_evt,
};
#endif

#ifdef EVFILT_SOCK
const dispatch_source_type_s _dispatch_source_type_sock = {
Expand Down