#include "config.h"
#endif
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#undef WIN32_LEAN_AND_MEAN
+#include "misc.h"
+#endif
#include <sys/types.h>
#include <sys/tree.h>
#ifdef HAVE_SYS_TIME_H
#include <sys/queue.h>
#include <stdio.h>
#include <stdlib.h>
+#ifndef WIN32
#include <unistd.h>
+#endif
#include <errno.h>
#include <string.h>
#include <err.h>
#ifdef HAVE_WORKING_KQUEUE
extern struct eventop kqops;
#endif
+#ifdef WIN32
+extern struct eventop win32ops;
+#endif
/* In order of preference */
struct eventop *eventops[] = {
#endif
#ifdef HAVE_SELECT
&selectops,
+#endif
+#ifdef WIN32
+ &win32ops,
#endif
NULL
};
/* Prototypes */
void event_queue_insert(struct event *, int);
void event_queue_remove(struct event *, int);
+int event_haveevents(void);
+void event_process_active(void);
+void timeout_insert(struct event *);
static RB_HEAD(event_tree, event) timetree;
static struct event_list activequeue;
while (ncalls) {
ncalls--;
ev->ev_ncalls = ncalls;
- (*ev->ev_callback)(ev->ev_fd, ev->ev_res, ev->ev_arg);
+ (*ev->ev_callback)((int)ev->ev_fd, ev->ev_res, ev->ev_arg);
}
}
}
{
ev->ev_callback = callback;
ev->ev_arg = arg;
+#ifdef WIN32
+ ev->ev_fd = (HANDLE)fd;
+ ev->overlap.hEvent = ev;
+#else
ev->ev_fd = fd;
+#endif
ev->ev_events = events;
ev->ev_flags = EVLIST_INIT;
ev->ev_ncalls = 0;
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 *);
struct eventop kqops = {
"kqueue",
if (getenv("EVENT_NOKQUEUE"))
return (NULL);
- memset(&kqop, 0, sizeof(kqop));
+ memset(&kqueueop, 0, sizeof(kqueueop));
/* Initalize the kernel queue */
return (NULL);
}
- kqop.kq = kq;
+ kqueueop.kq = kq;
/* Initalize fields */
- kqop.changes = malloc(NEVENT * sizeof(struct kevent));
- if (kqop.changes == NULL)
+ 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
struct pollfd *event_set;
struct event **event_back;
sigset_t evsigmask;
-} pop;
+} pollop;
void *poll_init (void);
int poll_add (void *, struct event *);
if (getenv("EVENT_NOPOLL"))
return (NULL);
- memset(&pop, 0, sizeof(pop));
+ memset(&pollop, 0, sizeof(pollop));
- evsignal_init(&pop.evsigmask);
+ evsignal_init(&pollop.evsigmask);
- return (&pop);
+ return (&pollop);
}
/*
#endif
#include "event.h"
+#include "evsignal.h"
extern struct event_list signalqueue;
int
evsignal_add(sigset_t *evsigmask, struct event *ev)
{
- int signal;
+ int evsignal;
if (ev->ev_events & (EV_READ|EV_WRITE))
errx(1, "%s: EV_SIGNAL incompatible use", __func__);
- signal = EVENT_SIGNAL(ev);
- sigaddset(evsigmask, signal);
+ evsignal = EVENT_SIGNAL(ev);
+ sigaddset(evsigmask, evsignal);
return (0);
}
int
evsignal_del(sigset_t *evsigmask, struct event *ev)
{
- int signal;
+ int evsignal;
- signal = EVENT_SIGNAL(ev);
- sigdelset(evsigmask, signal);
+ evsignal = EVENT_SIGNAL(ev);
+ sigdelset(evsigmask, evsignal);
needrecalc = 1;
return (sigaction(EVENT_SIGNAL(ev),(struct sigaction *)SIG_DFL, NULL));