ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.11
Committed: Sat Nov 3 21:58:51 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.10: +7 -8 lines
Log Message:
prepare for multiple bases

File Contents

# Content
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 #define EV_COMMON \
16 SV *self; /* contains this struct */ \
17 SV *cb_sv, *fh;
18
19 #ifndef EV_PROTOTYPES
20 # define EV_PROTOTYPES 0
21 #endif
22
23 #include <ev.h>
24
25 struct EVAPI {
26 I32 ver;
27 I32 rev;
28 #define EV_API_VERSION 1
29 #define EV_API_REVISION 0
30
31 /* perl fh or fd int to fd */
32 int (*sv_fileno) (SV *fh);
33 /* signal number/name to signum */
34 int (*sv_signum) (SV *fh);
35
36
37 /* same as libev functions */
38 ev_tstamp (*now)(void);
39 ev_tstamp (*(time))(void);
40 void (*method)(void);
41 void (*loop)(int flags);
42 void (*unloop)(int how);
43 void (*once)(int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
44 void (*io_start)(struct ev_io *);
45 void (*io_stop) (struct ev_io *);
46 void (*timer_start)(struct ev_timer *);
47 void (*timer_stop) (struct ev_timer *);
48 void (*timer_again)(struct ev_timer *);
49 void (*periodic_start)(struct ev_periodic *);
50 void (*periodic_stop) (struct ev_periodic *);
51 void (*signal_start)(struct ev_signal *);
52 void (*signal_stop) (struct ev_signal *);
53 void (*idle_start)(struct ev_idle *);
54 void (*idle_stop) (struct ev_idle *);
55 void (*prepare_start)(struct ev_prepare *);
56 void (*prepare_stop) (struct ev_prepare *);
57 void (*check_start)(struct ev_check *);
58 void (*check_stop) (struct ev_check *);
59 void (*child_start)(struct ev_child *);
60 void (*child_stop) (struct ev_child *);
61 };
62
63 #if !EV_PROTOTYPES
64 # define sv_fileno(sv) GEVAPI->sv_fileno (sv)
65 # define sv_signum(sv) GEVAPI->sv_signum (sv)
66 # define ev_now() GEVAPI->now ()
67 # define ev_time() GEVAPI->(time) ()
68 # define ev_method() GEVAPI->method ()
69 # define ev_loop(flags) GEVAPI->loop (flags)
70 # define ev_unloop() GEVAPI->unloop (int how)
71 # define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg))
72 # define ev_io_start(w) GEVAPI->io_start (w)
73 # define ev_io_stop(w) GEVAPI->io_stop (w)
74 # define ev_timer_start(w) GEVAPI->timer_start (w)
75 # define ev_timer_stop(w) GEVAPI->timer_stop (w)
76 # define ev_timer_again(w) GEVAPI->timer_again (w)
77 # define ev_periodic_start(w) GEVAPI->periodic_start (w)
78 # define ev_periodic_stop(w) GEVAPI->periodic_stop (w)
79 # define ev_signal_start(w) GEVAPI->signal_start (w)
80 # define ev_signal_stop(w) GEVAPI->signal_stop (w)
81 # define ev_idle_start(w) GEVAPI->idle_start (w)
82 # define ev_idle_stop(w) GEVAPI->idle_stop (w)
83 # define ev_prepare_start(w) GEVAPI->prepare_start (w)
84 # define ev_prepare_stop(w) GEVAPI->prepare_stop (w)
85 # define ev_check_start(w) GEVAPI->check_start (w)
86 # define ev_check_stop(w) GEVAPI->check_stop (w)
87 # define ev_child_start(w) GEVAPI->child_start (w)
88 # define ev_child_stop(w) GEVAPI->child_stop (w)
89 #endif
90
91 static struct EVAPI *GEVAPI;
92
93 #define I_EV_API(YourName) \
94 STMT_START { \
95 SV *sv = perl_get_sv ("EV::API", 0); \
96 if (!sv) croak ("EV::API not found"); \
97 GEVAPI = (struct EVAPI*) SvIV (sv); \
98 if (GEVAPI->ver != EV_API_VERSION \
99 || GEVAPI->rev < EV_API_REVISION) \
100 croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
101 GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
102 } STMT_END
103
104 #endif
105