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 |
|
|
8 | #define HAVE_EPOLL 0 |
9 | |
9 | |
10 | #define EV_COMMON \ |
10 | #define EV_PROTOTYPES 1 |
11 | SV *self; /* contains this struct */ \ |
|
|
12 | SV *cb_sv, *fh; |
|
|
13 | |
|
|
14 | #include "EV/EVAPI.h" |
11 | #include "EV/EVAPI.h" |
15 | |
12 | |
16 | #include "libev/ev.c" |
13 | #include "libev/ev.c" |
17 | |
14 | |
18 | typedef int Signal; |
15 | typedef int Signal; |
… | |
… | |
40 | for (signum = 1; signum < SIG_SIZE; ++signum) |
37 | for (signum = 1; signum < SIG_SIZE; ++signum) |
41 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
38 | if (strEQ (SvPV_nolen (sig), PL_sig_name [signum])) |
42 | return signum; |
39 | return signum; |
43 | |
40 | |
44 | return -1; |
41 | 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 | } |
42 | } |
61 | |
43 | |
62 | ///////////////////////////////////////////////////////////////////////////// |
44 | ///////////////////////////////////////////////////////////////////////////// |
63 | // Event |
45 | // Event |
64 | |
46 | |
… | |
… | |
219 | ///////////////////////////////////////////////////////////////////////////// |
201 | ///////////////////////////////////////////////////////////////////////////// |
220 | // XS interface functions |
202 | // XS interface functions |
221 | |
203 | |
222 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
204 | MODULE = EV PACKAGE = EV PREFIX = ev_ |
223 | |
205 | |
|
|
206 | PROTOTYPES: ENABLE |
|
|
207 | |
224 | BOOT: |
208 | BOOT: |
225 | { |
209 | { |
226 | int i; |
210 | int i; |
227 | HV *stash = gv_stashpv ("EV", 1); |
211 | HV *stash = gv_stashpv ("EV", 1); |
228 | |
212 | |
229 | static const struct { |
213 | static const struct { |
230 | const char *name; |
214 | const char *name; |
231 | IV iv; |
215 | IV iv; |
232 | } *civ, const_iv[] = { |
216 | } *civ, const_iv[] = { |
233 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
217 | # define const_iv(pfx, name) { # name, (IV) pfx ## name }, |
|
|
218 | const_iv (EV_, UNDEF) |
234 | const_iv (EV_, NONE) |
219 | const_iv (EV_, NONE) |
235 | const_iv (EV_, TIMEOUT) |
220 | const_iv (EV_, TIMEOUT) |
236 | const_iv (EV_, READ) |
221 | const_iv (EV_, READ) |
237 | const_iv (EV_, WRITE) |
222 | const_iv (EV_, WRITE) |
238 | const_iv (EV_, SIGNAL) |
223 | const_iv (EV_, SIGNAL) |
239 | const_iv (EV_, IDLE) |
224 | const_iv (EV_, IDLE) |
240 | const_iv (EV_, CHECK) |
225 | const_iv (EV_, CHECK) |
|
|
226 | const_iv (EV_, ERROR) |
241 | |
227 | |
242 | const_iv (EV, LOOP_ONESHOT) |
228 | const_iv (EV, LOOP_ONESHOT) |
243 | const_iv (EV, LOOP_NONBLOCK) |
229 | const_iv (EV, LOOP_NONBLOCK) |
244 | |
230 | |
245 | const_iv (EV, METHOD_NONE) |
231 | const_iv (EV, METHOD_NONE) |
… | |
… | |
264 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
250 | perl_get_sv ("EV::API", TRUE); /* silence 5.10 warning */ |
265 | |
251 | |
266 | /* the poor man's shared library emulator */ |
252 | /* the poor man's shared library emulator */ |
267 | evapi.ver = EV_API_VERSION; |
253 | evapi.ver = EV_API_VERSION; |
268 | evapi.rev = EV_API_REVISION; |
254 | evapi.rev = EV_API_REVISION; |
269 | evapi.once = api_once; |
|
|
270 | evapi.sv_fileno = sv_fileno; |
255 | evapi.sv_fileno = sv_fileno; |
271 | evapi.sv_signum = sv_signum; |
256 | evapi.sv_signum = sv_signum; |
272 | evapi.now = &ev_now; |
257 | evapi.now = &ev_now; |
273 | evapi.method = &ev_method; |
258 | evapi.method = &ev_method; |
274 | evapi.loop_done = &ev_loop_done; |
259 | evapi.loop_done = &ev_loop_done; |
275 | evapi.time = ev_time; |
260 | evapi.time = ev_time; |
276 | evapi.loop = ev_loop; |
261 | evapi.loop = ev_loop; |
|
|
262 | evapi.once = ev_once; |
277 | evapi.io_start = evio_start; |
263 | evapi.io_start = evio_start; |
278 | evapi.io_stop = evio_stop; |
264 | evapi.io_stop = evio_stop; |
279 | evapi.timer_start = evtimer_start; |
265 | evapi.timer_start = evtimer_start; |
280 | evapi.timer_stop = evtimer_stop; |
266 | evapi.timer_stop = evtimer_stop; |
281 | evapi.timer_again = evtimer_again; |
267 | evapi.timer_again = evtimer_again; |