summaryrefslogtreecommitdiff
path: root/lib/libevent/kqueue.c
diff options
context:
space:
mode:
authorBrad Smith <brad@cvs.openbsd.org>2004-04-28 06:53:13 +0000
committerBrad Smith <brad@cvs.openbsd.org>2004-04-28 06:53:13 +0000
commitf1a8f8a8a269fc9130712441a11947ca19cb17ad (patch)
tree4155a71d2ace6ece769bb248b1a8c3ae38b5c77e /lib/libevent/kqueue.c
parentc81d4960d450e1bb563668a3ebacc0638dcfc7d0 (diff)
update to libevent 0.8; keep local changes
ok markus@
Diffstat (limited to 'lib/libevent/kqueue.c')
-rw-r--r--lib/libevent/kqueue.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/lib/libevent/kqueue.c b/lib/libevent/kqueue.c
index 0e9ee45f0b2..29625e1cd73 100644
--- a/lib/libevent/kqueue.c
+++ b/lib/libevent/kqueue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kqueue.c,v 1.11 2004/01/05 19:20:18 markus Exp $ */
+/* $OpenBSD: kqueue.c,v 1.12 2004/04/28 06:53:12 brad Exp $ */
/*
* Copyright 2000-2002 Niels Provos <provos@citi.umich.edu>
@@ -12,10 +12,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by Niels Provos.
- * 4. The name of the author may not be used to endorse or promote products
+ * 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
@@ -59,7 +56,7 @@
#define log_error warn
#endif
-#ifdef HAVE_INTTYPES_H
+#if defined(HAVE_INTTYPES_H) && !defined(__OpenBSD__)
#define INTPTR(x) (intptr_t)x
#else
#define INTPTR(x) x
@@ -81,13 +78,14 @@ struct kqop {
struct kevent *events;
int nevents;
int kq;
-} kqop;
+} kqueueop;
void *kq_init (void);
int kq_add (void *, struct event *);
int kq_del (void *, struct event *);
int kq_recalc (void *, int);
int kq_dispatch (void *, struct timeval *);
+int kq_insert (struct kqop *, struct kevent *);
const struct eventop kqops = {
"kqueue",
@@ -107,29 +105,29 @@ kq_init(void)
if (!issetugid() && getenv("EVENT_NOKQUEUE"))
return (NULL);
- memset(&kqop, 0, sizeof(kqop));
+ memset(&kqueueop, 0, sizeof(kqueueop));
- /* Initialize the kernel queue */
+ /* Initalize the kernel queue */
if ((kq = kqueue()) == -1) {
log_error("kqueue");
return (NULL);
}
- kqop.kq = kq;
+ kqueueop.kq = kq;
- /* Initialize fields */
- kqop.changes = malloc(NEVENT * sizeof(struct kevent));
- if (kqop.changes == NULL)
+ /* Initalize fields */
+ kqueueop.changes = malloc(NEVENT * sizeof(struct kevent));
+ if (kqueueop.changes == NULL)
return (NULL);
- kqop.events = malloc(NEVENT * sizeof(struct kevent));
- if (kqop.events == NULL) {
- free (kqop.changes);
+ kqueueop.events = malloc(NEVENT * sizeof(struct kevent));
+ if (kqueueop.events == NULL) {
+ free (kqueueop.changes);
return (NULL);
}
- kqop.nevents = NEVENT;
+ kqueueop.nevents = NEVENT;
- return (&kqop);
+ return (&kqueueop);
}
int
@@ -157,7 +155,7 @@ kq_insert(struct kqop *kqop, struct kevent *kev)
}
kqop->changes = newchange;
- newresult = realloc(kqop->changes,
+ newresult = realloc(kqop->events,
nevents * sizeof(struct kevent));
/*
@@ -168,7 +166,7 @@ kq_insert(struct kqop *kqop, struct kevent *kev)
log_error("%s: malloc", __func__);
return (-1);
}
- kqop->events = newchange;
+ kqop->events = newresult;
kqop->nevents = nevents;
}
@@ -292,9 +290,11 @@ kq_add(void *arg, struct event *ev)
memset(&kev, 0, sizeof(kev));
kev.ident = ev->ev_fd;
kev.filter = EVFILT_READ;
- kev.flags = EV_ADD;
+#ifdef NOTE_EOF
/* Make it behave like select() and poll() */
kev.fflags = NOTE_EOF;
+#endif
+ kev.flags = EV_ADD;
if (!(ev->ev_events & EV_PERSIST))
kev.flags |= EV_ONESHOT;
kev.udata = INTPTR(ev);