1 | #include "EXTERN.h" |
1 | #include "EXTERN.h" |
2 | #include "perl.h" |
2 | #include "perl.h" |
3 | #include "XSUB.h" |
3 | #include "XSUB.h" |
4 | |
4 | |
5 | #include <math.h> |
|
|
6 | #include <netinet/in.h> |
5 | /*#include <netinet/in.h>*/ |
7 | |
6 | |
8 | #define TIMEOUT_NONE HUGE_VAL |
7 | #define TIMEOUT_NONE HUGE_VAL |
9 | |
8 | |
10 | #define EV_COMMON \ |
9 | #define EV_PROTOTYPES 1 |
11 | SV *self; /* contains this struct */ \ |
|
|
12 | SV *cb_sv, *fh; |
|
|
13 | |
|
|
14 | #include "EV/EVAPI.h" |
10 | #include "EV/EVAPI.h" |
15 | |
11 | |
16 | #include "libev/ev.c" |
12 | #include "libev/ev.c" |
17 | |
13 | |
18 | typedef int Signal; |
14 | typedef int Signal; |
… | |
… | |
40 | for (signum = 1; signum < SIG_SIZE; ++signum) |
36 | for (signum = 1; signum < SIG_SIZE; ++signum) |
41 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
37 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
42 | return signum; |
38 | return signum; |
43 | |
39 | |
44 | return -1; |
40 | return -1; |
45 | } |
|
|
46 | |
|
|
47 | static void |
|
|
48 | api_once (int fd, short events, double timeout, void (*cb)(int, short, void *), void *arg) |
|
|
49 | { |
|
|
50 | #if 0 |
|
|
51 | if (timeout >= 0.) |
|
|
52 | { |
|
|
53 | struct timeval tv; |
|
|
54 | tv_set (&tv, timeout); |
|
|
55 | event_once (fd, events, cb, arg, &tv); |
|
|
56 | } |
|
|
57 | else |
|
|
58 | event_once (fd, events, cb, arg, 0); |
|
|
59 | #endif |
|
|
60 | } |
41 | } |
61 | |
42 | |
62 | ///////////////////////////////////////////////////////////////////////////// |
43 | ///////////////////////////////////////////////////////////////////////////// |
63 | // Event |
44 | // Event |
64 | |
45 | |
… | |
… | |
229 | static const struct { |
210 | static const struct { |
230 | const char *name; |
211 | const char *name; |
231 | IV iv; |
212 | IV iv; |
232 | } *civ, const_iv[] = { |
213 | } *civ, const_iv[] = { |
233 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
214 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
215 | const_iv (EV_, UNDEF) |
234 | const_iv (EV_, NONE) |
216 | const_iv (EV_, NONE) |
235 | const_iv (EV_, TIMEOUT) |
217 | const_iv (EV_, TIMEOUT) |
236 | const_iv (EV_, READ) |
218 | const_iv (EV_, READ) |
237 | const_iv (EV_, WRITE) |
219 | const_iv (EV_, WRITE) |
238 | const_iv (EV_, SIGNAL) |
220 | const_iv (EV_, SIGNAL) |
239 | const_iv (EV_, IDLE) |
221 | const_iv (EV_, IDLE) |
240 | const_iv (EV_, CHECK) |
222 | const_iv (EV_, CHECK) |
|
|
223 | const_iv (EV_, ERROR) |
241 | |
224 | |
242 | const_iv (EV, LOOP_ONESHOT) |
225 | const_iv (EV, LOOP_ONESHOT) |
243 | const_iv (EV, LOOP_NONBLOCK) |
226 | const_iv (EV, LOOP_NONBLOCK) |
244 | |
227 | |
245 | const_iv (EV, METHOD_NONE) |
228 | const_iv (EV, METHOD_NONE) |
… | |
… | |
264 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
247 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
265 | |
248 | |
266 | /* the poor man's shared library emulator */ |
249 | /* the poor man's shared library emulator */ |
267 | evapi.ver = EV_API_VERSION; |
250 | evapi.ver = EV_API_VERSION; |
268 | evapi.rev = EV_API_REVISION; |
251 | evapi.rev = EV_API_REVISION; |
269 | evapi.once = api_once; |
|
|
270 | evapi.sv_fileno = sv_fileno; |
252 | evapi.sv_fileno = sv_fileno; |
271 | evapi.sv_signum = sv_signum; |
253 | evapi.sv_signum = sv_signum; |
272 | evapi.now = &ev_now; |
254 | evapi.now = &ev_now; |
273 | evapi.method = &ev_method; |
255 | evapi.method = &ev_method; |
274 | evapi.loop_done = &ev_loop_done; |
256 | evapi.loop_done = &ev_loop_done; |
275 | evapi.time = ev_time; |
257 | evapi.time = ev_time; |
276 | evapi.loop = ev_loop; |
258 | evapi.loop = ev_loop; |
|
|
259 | evapi.once = ev_once; |
277 | evapi.io_start = evio_start; |
260 | evapi.io_start = evio_start; |
278 | evapi.io_stop = evio_stop; |
261 | evapi.io_stop = evio_stop; |
279 | evapi.timer_start = evtimer_start; |
262 | evapi.timer_start = evtimer_start; |
280 | evapi.timer_stop = evtimer_stop; |
263 | evapi.timer_stop = evtimer_stop; |
281 | evapi.timer_again = evtimer_again; |
264 | evapi.timer_again = evtimer_again; |