kqop
kq_insert(struct kqop *kqop, struct kevent *kev)
int nevents = kqop->nevents;
if (kqop->nchanges == nevents) {
newchange = recallocarray(kqop->changes,
kqop->nevents, nevents, sizeof(struct kevent));
kqop->changes = newchange;
newresult = recallocarray(kqop->events,
kqop->nevents, nevents, sizeof(struct kevent));
kqop->events = newresult;
kqop->nevents = nevents;
memcpy(&kqop->changes[kqop->nchanges++], kev, sizeof(struct kevent));
struct kqop *kqop = arg;
struct kevent *changes = kqop->changes;
struct kevent *events = kqop->events;
res = kevent(kqop->kq, kqop->nchanges ? changes : NULL, kqop->nchanges,
events, kqop->nevents, ts_p);
kqop->nchanges = 0;
struct kqop *kqop = arg;
if (TAILQ_EMPTY(&kqop->evsigevents[nsignal])) {
kev.udata = &kqop->evsigevents[nsignal];
if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1)
TAILQ_INSERT_TAIL(&kqop->evsigevents[nsignal], ev,
if (kq_insert(kqop, &kev) == -1)
if (kq_insert(kqop, &kev) == -1)
struct kqop *kqop = arg;
TAILQ_REMOVE(&kqop->evsigevents[nsignal], ev, ev_signal_next);
if (TAILQ_EMPTY(&kqop->evsigevents[nsignal])) {
if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1)
for (i = j = 0; i < kqop->nchanges; i++) {
if (kqop->changes[i].udata == ev &&
(kqop->changes[i].flags & EV_ADD) != 0)
memcpy(&kqop->changes[j], &kqop->changes[i],
if (kqop->nchanges != j) {
kqop->nchanges = j;
if (kq_insert(kqop, &kev) == -1)
if (kq_insert(kqop, &kev) == -1)
struct kqop *kqop = arg;
free(kqop->changes);
free(kqop->events);
if (kqop->kq >= 0 && kqop->pid == getpid())
close(kqop->kq);
memset(kqop, 0, sizeof(struct kqop));
free(kqop);
static int kq_insert (struct kqop *, struct kevent *);
struct kqop *kqueueop;
if (!(kqueueop = calloc(1, sizeof(struct kqop))))