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 |
root |
1.38 |
int e_flags; /* cheap on 64 bit systems */ \ |
17 |
root |
1.36 |
SV *loop; \ |
18 |
root |
1.50 |
SV *self; /* contains this struct */ \ |
19 |
root |
1.18 |
SV *cb_sv, *fh, *data; |
20 |
root |
1.7 |
|
21 |
|
|
#ifndef EV_PROTOTYPES |
22 |
|
|
# define EV_PROTOTYPES 0 |
23 |
|
|
#endif |
24 |
|
|
|
25 |
root |
1.35 |
#ifndef EV_H |
26 |
|
|
# define EV_H <EV/ev.h> |
27 |
|
|
#endif |
28 |
|
|
|
29 |
|
|
#include EV_H |
30 |
|
|
|
31 |
root |
1.1 |
struct EVAPI { |
32 |
|
|
I32 ver; |
33 |
|
|
I32 rev; |
34 |
root |
1.50 |
#define EV_API_VERSION 5 |
35 |
root |
1.55 |
#define EV_API_REVISION 1 |
36 |
root |
1.1 |
|
37 |
root |
1.33 |
struct ev_loop *default_loop; |
38 |
|
|
unsigned int supported_backends; |
39 |
|
|
unsigned int recommended_backends; |
40 |
|
|
unsigned int embeddable_backends; |
41 |
|
|
|
42 |
root |
1.47 |
/* TODO: remove on major API bump */ |
43 |
root |
1.4 |
/* perl fh or fd int to fd */ |
44 |
|
|
int (*sv_fileno) (SV *fh); |
45 |
|
|
/* signal number/name to signum */ |
46 |
|
|
int (*sv_signum) (SV *fh); |
47 |
|
|
|
48 |
|
|
/* same as libev functions */ |
49 |
root |
1.41 |
ev_tstamp (*time_)(void); |
50 |
|
|
void (*sleep_)(ev_tstamp); |
51 |
root |
1.50 |
|
52 |
root |
1.33 |
struct ev_loop *(*loop_new)(unsigned int); |
53 |
|
|
void (*loop_destroy)(EV_P); |
54 |
|
|
void (*loop_fork)(EV_P); |
55 |
root |
1.50 |
unsigned int (*backend)(EV_P); |
56 |
root |
1.52 |
unsigned int (*iteration)(EV_P); |
57 |
|
|
unsigned int (*depth)(EV_P); |
58 |
root |
1.50 |
ev_tstamp (*now)(EV_P); |
59 |
|
|
void (*now_update)(EV_P); |
60 |
root |
1.55 |
int (*run)(EV_P_ int flags); |
61 |
root |
1.53 |
void (*break_)(EV_P_ int how); |
62 |
root |
1.50 |
void (*suspend)(EV_P); |
63 |
|
|
void (*resume) (EV_P); |
64 |
|
|
void (*ref) (EV_P); |
65 |
root |
1.29 |
void (*unref)(EV_P); |
66 |
root |
1.50 |
void (*set_userdata)(EV_P_ void *data); |
67 |
|
|
void *(*userdata) (EV_P); |
68 |
|
|
void (*set_loop_release_cb) (EV_P_ void (*release)(EV_P), void (*acquire)(EV_P)); |
69 |
|
|
void (*set_invoke_pending_cb)(EV_P_ void (*invoke_pending_cb)(EV_P)); |
70 |
|
|
unsigned int (*pending_count)(EV_P); |
71 |
|
|
void (*invoke_pending) (EV_P); |
72 |
root |
1.52 |
void (*verify) (EV_P); |
73 |
root |
1.50 |
|
74 |
root |
1.29 |
void (*once)(EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
75 |
root |
1.50 |
|
76 |
|
|
void (*invoke)(EV_P_ void *, int); |
77 |
root |
1.32 |
int (*clear_pending)(EV_P_ void *); |
78 |
root |
1.50 |
|
79 |
root |
1.30 |
void (*io_start)(EV_P_ ev_io *); |
80 |
|
|
void (*io_stop) (EV_P_ ev_io *); |
81 |
|
|
void (*timer_start)(EV_P_ ev_timer *); |
82 |
|
|
void (*timer_stop) (EV_P_ ev_timer *); |
83 |
|
|
void (*timer_again)(EV_P_ ev_timer *); |
84 |
root |
1.50 |
ev_tstamp (*timer_remaining) (EV_P_ ev_timer *); |
85 |
root |
1.30 |
void (*periodic_start)(EV_P_ ev_periodic *); |
86 |
|
|
void (*periodic_stop) (EV_P_ ev_periodic *); |
87 |
|
|
void (*signal_start)(EV_P_ ev_signal *); |
88 |
|
|
void (*signal_stop) (EV_P_ ev_signal *); |
89 |
|
|
void (*child_start)(EV_P_ ev_child *); |
90 |
|
|
void (*child_stop) (EV_P_ ev_child *); |
91 |
|
|
void (*stat_start)(EV_P_ ev_stat *); |
92 |
|
|
void (*stat_stop) (EV_P_ ev_stat *); |
93 |
|
|
void (*stat_stat) (EV_P_ ev_stat *); |
94 |
|
|
void (*idle_start)(EV_P_ ev_idle *); |
95 |
|
|
void (*idle_stop) (EV_P_ ev_idle *); |
96 |
|
|
void (*prepare_start)(EV_P_ ev_prepare *); |
97 |
|
|
void (*prepare_stop) (EV_P_ ev_prepare *); |
98 |
|
|
void (*check_start)(EV_P_ ev_check *); |
99 |
|
|
void (*check_stop) (EV_P_ ev_check *); |
100 |
root |
1.33 |
void (*embed_start)(EV_P_ ev_embed *); |
101 |
|
|
void (*embed_stop) (EV_P_ ev_embed *); |
102 |
|
|
void (*embed_sweep)(EV_P_ ev_embed *); |
103 |
|
|
void (*fork_start) (EV_P_ ev_fork *); |
104 |
|
|
void (*fork_stop) (EV_P_ ev_fork *); |
105 |
root |
1.54 |
void (*cleanup_start) (EV_P_ ev_cleanup *); |
106 |
|
|
void (*cleanup_stop) (EV_P_ ev_cleanup *); |
107 |
root |
1.43 |
void (*async_start)(EV_P_ ev_async *); |
108 |
|
|
void (*async_stop) (EV_P_ ev_async *); |
109 |
|
|
void (*async_send) (EV_P_ ev_async *); |
110 |
root |
1.1 |
}; |
111 |
|
|
|
112 |
root |
1.7 |
#if !EV_PROTOTYPES |
113 |
root |
1.33 |
# undef EV_DEFAULT |
114 |
|
|
# undef EV_DEFAULT_ |
115 |
root |
1.42 |
# undef EV_DEFAULT_UC |
116 |
|
|
# undef EV_DEFAULT_UC_ |
117 |
root |
1.33 |
# undef EV_A_ |
118 |
|
|
# define EV_DEFAULT GEVAPI->default_loop |
119 |
root |
1.42 |
# define EV_DEFAULT_UC GEVAPI->default_loop |
120 |
root |
1.33 |
# define ev_supported_backends() GEVAPI->supported_backends |
121 |
|
|
# define ev_recommended_backends() GEVAPI->recommended_backends |
122 |
|
|
# define ev_embeddable_backends() GEVAPI->embeddable_backends |
123 |
|
|
|
124 |
|
|
# define sv_fileno(sv) GEVAPI->sv_fileno (sv) |
125 |
|
|
# define sv_signum(sv) GEVAPI->sv_signum (sv) |
126 |
root |
1.50 |
|
127 |
root |
1.41 |
# define ev_time() GEVAPI->time_ () |
128 |
|
|
# define ev_sleep(time) GEVAPI->sleep_ ((time)) |
129 |
root |
1.50 |
|
130 |
root |
1.33 |
# define ev_loop_new(flags) GEVAPI->loop_new ((flags)) |
131 |
|
|
# define ev_loop_destroy(loop) GEVAPI->loop_destroy ((loop)) |
132 |
|
|
# define ev_loop_fork(loop) GEVAPI->loop_fork ((loop)) |
133 |
root |
1.50 |
# define ev_backend(loop) GEVAPI->backend ((loop)) |
134 |
root |
1.52 |
# define ev_iteration(loop) GEVAPI->iteration ((loop)) |
135 |
|
|
# define ev_depth(loop) GEVAPI->depth ((depth)) |
136 |
root |
1.33 |
# define ev_now(loop) GEVAPI->now ((loop)) |
137 |
root |
1.44 |
# define ev_now_update(loop) GEVAPI->now_update ((loop)) |
138 |
root |
1.53 |
# define ev_run(l,flags) GEVAPI->run ((l), (flags)) |
139 |
|
|
# define ev_break(loop,how) GEVAPI->break_ ((loop), (how)) |
140 |
root |
1.44 |
# define ev_suspend(loop) GEVAPI->suspend ((loop)) |
141 |
|
|
# define ev_resume(loop) GEVAPI->resume ((loop)) |
142 |
root |
1.50 |
# define ev_ref(loop) GEVAPI->ref (loop) |
143 |
|
|
# define ev_unref(loop) GEVAPI->unref (loop) |
144 |
|
|
# define ev_set_userdata(l,p) GEVAPI->set_userdata ((l), (p)) |
145 |
|
|
# define ev_userdata(l) GEVAPI->userdata (l) |
146 |
|
|
# define ev_set_loop_release_cb(l,r,a) GEVAPI->set_loop_release_cb ((l), (r), (a)) |
147 |
|
|
# define ev_set_invoke_pending_cb(l,c) GEVAPI->set_invoke_pending_cb ((l), (c)) |
148 |
root |
1.47 |
# define ev_invoke_pending(l) GEVAPI->invoke_pending ((l)) |
149 |
root |
1.48 |
# define ev_pending_count(l) GEVAPI->pending_count ((l)) |
150 |
root |
1.52 |
# define ev_verify(l) GEVAPI->verify ((l)) |
151 |
root |
1.50 |
|
152 |
root |
1.33 |
# define ev_once(loop,fd,events,timeout,cb,arg) GEVAPI->once ((loop), (fd), (events), (timeout), (cb), (arg)) |
153 |
root |
1.50 |
|
154 |
|
|
# define ev_invoke(l,w,rev) GEVAPI->invoke ((l), (w), (rev)) |
155 |
|
|
# define ev_clear_pending(l,w) GEVAPI->clear_pending ((l), (w)) |
156 |
root |
1.33 |
# define ev_io_start(l,w) GEVAPI->io_start ((l), (w)) |
157 |
|
|
# define ev_io_stop(l,w) GEVAPI->io_stop ((l), (w)) |
158 |
|
|
# define ev_timer_start(l,w) GEVAPI->timer_start ((l), (w)) |
159 |
|
|
# define ev_timer_stop(l,w) GEVAPI->timer_stop ((l), (w)) |
160 |
|
|
# define ev_timer_again(l,w) GEVAPI->timer_again ((l), (w)) |
161 |
root |
1.49 |
# define ev_timer_remaining(l,w) GEVAPI->timer_remaining ((l), (w)) |
162 |
root |
1.33 |
# define ev_periodic_start(l,w) GEVAPI->periodic_start ((l), (w)) |
163 |
|
|
# define ev_periodic_stop(l,w) GEVAPI->periodic_stop ((l), (w)) |
164 |
|
|
# define ev_signal_start(l,w) GEVAPI->signal_start ((l), (w)) |
165 |
|
|
# define ev_signal_stop(l,w) GEVAPI->signal_stop ((l), (w)) |
166 |
|
|
# define ev_idle_start(l,w) GEVAPI->idle_start ((l), (w)) |
167 |
|
|
# define ev_idle_stop(l,w) GEVAPI->idle_stop ((l), (w)) |
168 |
|
|
# define ev_prepare_start(l,w) GEVAPI->prepare_start ((l), (w)) |
169 |
|
|
# define ev_prepare_stop(l,w) GEVAPI->prepare_stop ((l), (w)) |
170 |
|
|
# define ev_check_start(l,w) GEVAPI->check_start ((l), (w)) |
171 |
|
|
# define ev_check_stop(l,w) GEVAPI->check_stop ((l), (w)) |
172 |
|
|
# define ev_child_start(l,w) GEVAPI->child_start ((l), (w)) |
173 |
|
|
# define ev_child_stop(l,w) GEVAPI->child_stop ((l), (w)) |
174 |
|
|
# define ev_stat_start(l,w) GEVAPI->stat_start ((l), (w)) |
175 |
|
|
# define ev_stat_stop(l,w) GEVAPI->stat_stop ((l), (w)) |
176 |
|
|
# define ev_stat_stat(l,w) GEVAPI->stat_stat ((l), (w)) |
177 |
|
|
# define ev_embed_start(l,w) GEVAPI->embed_start ((l), (w)) |
178 |
|
|
# define ev_embed_stop(l,w) GEVAPI->embed_stop ((l), (w)) |
179 |
|
|
# define ev_embed_sweep(l,w) GEVAPI->embed_sweep ((l), (w)) |
180 |
root |
1.39 |
# define ev_fork_start(l,w) GEVAPI->fork_start ((l), (w)) |
181 |
|
|
# define ev_fork_stop(l,w) GEVAPI->fork_stop ((l), (w)) |
182 |
root |
1.54 |
# define ev_cleanup_start(l,w) GEVAPI->cleanup_start ((l), (w)) |
183 |
|
|
# define ev_cleanup_stop(l,w) GEVAPI->cleanup_stop ((l), (w)) |
184 |
root |
1.39 |
# define ev_async_start(l,w) GEVAPI->async_start ((l), (w)) |
185 |
|
|
# define ev_async_stop(l,w) GEVAPI->async_stop ((l), (w)) |
186 |
|
|
# define ev_async_send(l,w) GEVAPI->async_send ((l), (w)) |
187 |
root |
1.7 |
#endif |
188 |
root |
1.2 |
|
189 |
root |
1.1 |
static struct EVAPI *GEVAPI; |
190 |
|
|
|
191 |
root |
1.56 |
#define I_EV_API(YourName) \ |
192 |
|
|
STMT_START { \ |
193 |
|
|
SV *sv = perl_get_sv ("EV::API", 0); \ |
194 |
|
|
if (!sv) croak ("EV::API not found"); \ |
195 |
|
|
GEVAPI = (struct EVAPI*) SvIV (sv); \ |
196 |
|
|
if (GEVAPI->ver != EV_API_VERSION \ |
197 |
|
|
|| GEVAPI->rev < EV_API_REVISION) \ |
198 |
|
|
croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile '%s'", \ |
199 |
|
|
(int)GEVAPI->ver, (int)GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \ |
200 |
root |
1.1 |
} STMT_END |
201 |
|
|
|
202 |
|
|
#endif |
203 |
|
|
|