ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.15
Committed: Mon Nov 5 18:03:52 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.14: +0 -1 lines
Log Message:
*** empty log message ***

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