… | |
… | |
35 | |
35 | |
36 | #ifndef WIN32 |
36 | #ifndef WIN32 |
37 | # include <sys/time.h> |
37 | # include <sys/time.h> |
38 | #endif |
38 | #endif |
39 | |
39 | |
40 | #include "ev.h" |
40 | #ifdef EV_EVENT_H |
|
|
41 | # include EV_EVENT_H |
|
|
42 | #else |
41 | #include "event.h" |
43 | # include "event.h" |
|
|
44 | #endif |
42 | |
45 | |
43 | #if EV_MULTIPLICITY |
46 | #if EV_MULTIPLICITY |
44 | # define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base |
47 | # define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base |
45 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
48 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
46 | #else |
49 | #else |
… | |
… | |
136 | x_cb (struct event *ev, int revents) |
139 | x_cb (struct event *ev, int revents) |
137 | { |
140 | { |
138 | revents &= EV_READ | EV_WRITE | EV_TIMEOUT | EV_SIGNAL; |
141 | revents &= EV_READ | EV_WRITE | EV_TIMEOUT | EV_SIGNAL; |
139 | |
142 | |
140 | ev->ev_res = revents; |
143 | ev->ev_res = revents; |
141 | ev->ev_callback (ev->ev_fd, revents, ev->ev_arg); |
144 | ev->ev_callback (ev->ev_fd, (short)revents, ev->ev_arg); |
142 | } |
145 | } |
143 | |
146 | |
144 | static void |
147 | static void |
145 | x_cb_sig (EV_P_ struct ev_signal *w, int revents) |
148 | x_cb_sig (EV_P_ struct ev_signal *w, int revents) |
146 | { |
149 | { |
… | |
… | |
176 | } |
179 | } |
177 | |
180 | |
178 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg) |
181 | void event_set (struct event *ev, int fd, short events, void (*cb)(int, short, void *), void *arg) |
179 | { |
182 | { |
180 | if (events & EV_SIGNAL) |
183 | if (events & EV_SIGNAL) |
181 | ev_watcher_init (&ev->iosig.sig, x_cb_sig); |
184 | ev_init (&ev->iosig.sig, x_cb_sig); |
182 | else |
185 | else |
183 | ev_watcher_init (&ev->iosig.io, x_cb_io); |
186 | ev_init (&ev->iosig.io, x_cb_io); |
184 | |
187 | |
185 | ev_watcher_init (&ev->to, x_cb_to); |
188 | ev_init (&ev->to, x_cb_to); |
186 | |
189 | |
187 | ev->ev_base = x_cur; /* not threadsafe, but its like libevent works */ |
190 | ev->ev_base = x_cur; /* not threadsafe, but its like libevent works */ |
188 | ev->ev_fd = fd; |
191 | ev->ev_fd = fd; |
189 | ev->ev_events = events; |
192 | ev->ev_events = events; |
190 | ev->ev_pri = 0; |
193 | ev->ev_pri = 0; |
… | |
… | |
353 | static void |
356 | static void |
354 | x_once_cb (int revents, void *arg) |
357 | x_once_cb (int revents, void *arg) |
355 | { |
358 | { |
356 | struct x_once *once = (struct x_once *)arg; |
359 | struct x_once *once = (struct x_once *)arg; |
357 | |
360 | |
358 | once->cb (once->fd, revents, once->arg); |
361 | once->cb (once->fd, (short)revents, once->arg); |
359 | free (once); |
362 | free (once); |
360 | } |
363 | } |
361 | |
364 | |
362 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
365 | int event_base_once (struct event_base *base, int fd, short events, void (*cb)(int, short, void *), void *arg, struct timeval *tv) |
363 | { |
366 | { |