1 |
root |
1.1 |
#ifndef EV_API_H |
2 |
|
|
#define EV_API_H |
3 |
|
|
|
4 |
|
|
#include "EXTERN.h" |
5 |
|
|
#include "perl.h" |
6 |
|
|
#include "XSUB.h" |
7 |
|
|
|
8 |
|
|
#ifndef pTHX_ |
9 |
|
|
# define pTHX_ |
10 |
|
|
# define aTHX_ |
11 |
|
|
# define pTHX |
12 |
|
|
# define aTHX |
13 |
|
|
#endif |
14 |
|
|
|
15 |
root |
1.23 |
#define EV_COMMON \ |
16 |
|
|
int flags; /* cheap on 64 bit systems */ \ |
17 |
|
|
SV *self; /* contains this struct */ \ |
18 |
root |
1.18 |
SV *cb_sv, *fh, *data; |
19 |
root |
1.7 |
|
20 |
|
|
#ifndef EV_PROTOTYPES |
21 |
|
|
# define EV_PROTOTYPES 0 |
22 |
|
|
#endif |
23 |
|
|
|
24 |
root |
1.14 |
#define EV_STANDALONE 1 |
25 |
root |
1.12 |
#define EV_MULTIPLICITY 0 |
26 |
|
|
|
27 |
root |
1.4 |
#include <ev.h> |
28 |
root |
1.1 |
|
29 |
|
|
struct EVAPI { |
30 |
|
|
I32 ver; |
31 |
|
|
I32 rev; |
32 |
root |
1.25 |
#define EV_API_VERSION 2 |
33 |
|
|
#define EV_API_REVISION 0 |
34 |
root |
1.1 |
|
35 |
root |
1.4 |
/* perl fh or fd int to fd */ |
36 |
|
|
int (*sv_fileno) (SV *fh); |
37 |
|
|
/* signal number/name to signum */ |
38 |
|
|
int (*sv_signum) (SV *fh); |
39 |
|
|
|
40 |
|
|
/* same as libev functions */ |
41 |
root |
1.11 |
ev_tstamp (*now)(void); |
42 |
root |
1.4 |
ev_tstamp (*(time))(void); |
43 |
root |
1.20 |
unsigned int (*backend)(void); |
44 |
root |
1.4 |
void (*loop)(int flags); |
45 |
root |
1.11 |
void (*unloop)(int how); |
46 |
root |
1.25 |
void (*ref)(void); |
47 |
|
|
void (*unref)(void); |
48 |
root |
1.7 |
void (*once)(int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
49 |
root |
1.4 |
void (*io_start)(struct ev_io *); |
50 |
|
|
void (*io_stop) (struct ev_io *); |
51 |
|
|
void (*timer_start)(struct ev_timer *); |
52 |
|
|
void (*timer_stop) (struct ev_timer *); |
53 |
root |
1.6 |
void (*timer_again)(struct ev_timer *); |
54 |
root |
1.4 |
void (*periodic_start)(struct ev_periodic *); |
55 |
|
|
void (*periodic_stop) (struct ev_periodic *); |
56 |
|
|
void (*signal_start)(struct ev_signal *); |
57 |
|
|
void (*signal_stop) (struct ev_signal *); |
58 |
root |
1.26 |
void (*child_start)(struct ev_child *); |
59 |
|
|
void (*child_stop) (struct ev_child *); |
60 |
|
|
void (*stat_start)(struct ev_stat *); |
61 |
|
|
void (*stat_stop) (struct ev_stat *); |
62 |
|
|
void (*stat_stat) (struct ev_stat *); |
63 |
root |
1.4 |
void (*idle_start)(struct ev_idle *); |
64 |
|
|
void (*idle_stop) (struct ev_idle *); |
65 |
root |
1.8 |
void (*prepare_start)(struct ev_prepare *); |
66 |
|
|
void (*prepare_stop) (struct ev_prepare *); |
67 |
root |
1.4 |
void (*check_start)(struct ev_check *); |
68 |
|
|
void (*check_stop) (struct ev_check *); |
69 |
root |
1.25 |
void *embed_start_dummy; |
70 |
|
|
void *embed_stop_dummy; |
71 |
|
|
void *embed_sweep_dummy; |
72 |
root |
1.1 |
}; |
73 |
|
|
|
74 |
root |
1.7 |
#if !EV_PROTOTYPES |
75 |
|
|
# define sv_fileno(sv) GEVAPI->sv_fileno (sv) |
76 |
|
|
# define sv_signum(sv) GEVAPI->sv_signum (sv) |
77 |
root |
1.11 |
# define ev_now() GEVAPI->now () |
78 |
root |
1.27 |
# define ev_time() (GEVAPI->time) () |
79 |
root |
1.20 |
# define ev_backend() GEVAPI->backend () |
80 |
root |
1.7 |
# define ev_loop(flags) GEVAPI->loop (flags) |
81 |
root |
1.24 |
# define ev_unloop(how) GEVAPI->unloop (how) |
82 |
root |
1.7 |
# define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg)) |
83 |
root |
1.10 |
# define ev_io_start(w) GEVAPI->io_start (w) |
84 |
|
|
# define ev_io_stop(w) GEVAPI->io_stop (w) |
85 |
|
|
# define ev_timer_start(w) GEVAPI->timer_start (w) |
86 |
|
|
# define ev_timer_stop(w) GEVAPI->timer_stop (w) |
87 |
|
|
# define ev_timer_again(w) GEVAPI->timer_again (w) |
88 |
|
|
# define ev_periodic_start(w) GEVAPI->periodic_start (w) |
89 |
|
|
# define ev_periodic_stop(w) GEVAPI->periodic_stop (w) |
90 |
|
|
# define ev_signal_start(w) GEVAPI->signal_start (w) |
91 |
|
|
# define ev_signal_stop(w) GEVAPI->signal_stop (w) |
92 |
|
|
# define ev_idle_start(w) GEVAPI->idle_start (w) |
93 |
|
|
# define ev_idle_stop(w) GEVAPI->idle_stop (w) |
94 |
|
|
# define ev_prepare_start(w) GEVAPI->prepare_start (w) |
95 |
|
|
# define ev_prepare_stop(w) GEVAPI->prepare_stop (w) |
96 |
|
|
# define ev_check_start(w) GEVAPI->check_start (w) |
97 |
|
|
# define ev_check_stop(w) GEVAPI->check_stop (w) |
98 |
|
|
# define ev_child_start(w) GEVAPI->child_start (w) |
99 |
|
|
# define ev_child_stop(w) GEVAPI->child_stop (w) |
100 |
root |
1.25 |
# define ev_stat_start(w) GEVAPI->stat_start (w) |
101 |
|
|
# define ev_stat_stop(w) GEVAPI->stat_stop (w) |
102 |
|
|
# define ev_stat_stat(w) GEVAPI->stat_stat (w) |
103 |
root |
1.22 |
# define ev_ref() GEVAPI->ref () |
104 |
|
|
# define ev_unref() GEVAPI->unref () |
105 |
root |
1.7 |
#endif |
106 |
root |
1.2 |
|
107 |
root |
1.1 |
static struct EVAPI *GEVAPI; |
108 |
|
|
|
109 |
|
|
#define I_EV_API(YourName) \ |
110 |
|
|
STMT_START { \ |
111 |
|
|
SV *sv = perl_get_sv ("EV::API", 0); \ |
112 |
|
|
if (!sv) croak ("EV::API not found"); \ |
113 |
root |
1.5 |
GEVAPI = (struct EVAPI*) SvIV (sv); \ |
114 |
root |
1.1 |
if (GEVAPI->ver != EV_API_VERSION \ |
115 |
|
|
|| GEVAPI->rev < EV_API_REVISION) \ |
116 |
|
|
croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \ |
117 |
|
|
GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \ |
118 |
|
|
} STMT_END |
119 |
|
|
|
120 |
|
|
#endif |
121 |
|
|
|