ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.8
Committed: Wed Oct 31 18:28:00 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.7: +5 -1 lines
Log Message:
add prepare watcher

File Contents

# User Rev Content
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.7 #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 root 1.4 #include <ev.h>
24 root 1.1
25     struct EVAPI {
26     I32 ver;
27     I32 rev;
28 root 1.8 #define EV_API_VERSION 1
29 root 1.1 #define EV_API_REVISION 0
30    
31 root 1.4 /* 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     /* libev global variables (note: references!) */
37     ev_tstamp *now;
38     int *method;
39     int *loop_done;
40    
41     /* same as libev functions */
42     ev_tstamp (*(time))(void);
43     void (*loop)(int flags);
44 root 1.7 void (*once)(int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
45 root 1.4 void (*io_start)(struct ev_io *);
46     void (*io_stop) (struct ev_io *);
47     void (*timer_start)(struct ev_timer *);
48     void (*timer_stop) (struct ev_timer *);
49 root 1.6 void (*timer_again)(struct ev_timer *);
50 root 1.4 void (*periodic_start)(struct ev_periodic *);
51     void (*periodic_stop) (struct ev_periodic *);
52     void (*signal_start)(struct ev_signal *);
53     void (*signal_stop) (struct ev_signal *);
54     void (*idle_start)(struct ev_idle *);
55     void (*idle_stop) (struct ev_idle *);
56 root 1.8 void (*prepare_start)(struct ev_prepare *);
57     void (*prepare_stop) (struct ev_prepare *);
58 root 1.4 void (*check_start)(struct ev_check *);
59     void (*check_stop) (struct ev_check *);
60 root 1.1 };
61    
62 root 1.7 #if !EV_PROTOTYPES
63     # define sv_fileno(sv) GEVAPI->sv_fileno (sv)
64     # define sv_signum(sv) GEVAPI->sv_signum (sv)
65     # define ev_now *GEVAPI->now
66     # define ev_method *GEVAPI->method
67     # define ev_loop_done *GEVAPI->loop_done
68     # define ev_time() GEVAPI->(time)()
69     # define ev_loop(flags) GEVAPI->loop (flags)
70     # define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg))
71     # define evio_start(w) GEVAPI->io_start (w)
72     # define evio_stop(w) GEVAPI->io_stop (w)
73     # define evtimer_start(w) GEVAPI->timer_start (w)
74     # define evtimer_stop(w) GEVAPI->timer_stop (w)
75     # define evtimer_again(w) GEVAPI->timer_again (w)
76     # define evperiodic_start(w) GEVAPI->periodic_start (w)
77     # define evperiodic_stop(w) GEVAPI->periodic_stop (w)
78     # define evsignal_start(w) GEVAPI->signal_start (w)
79     # define evsignal_stop(w) GEVAPI->signal_stop (w)
80     # define evidle_start(w) GEVAPI->idle_start (w)
81     # define evidle_stop(w) GEVAPI->idle_stop (w)
82 root 1.8 # define evprepare_start(w) GEVAPI->prepare_start (w)
83     # define evprepare_stop(w) GEVAPI->prepare_stop (w)
84 root 1.7 # define evcheck_start(w) GEVAPI->check_start (w)
85     # define evcheck_stop(w) GEVAPI->check_stop (w)
86     #endif
87 root 1.2
88 root 1.1 static struct EVAPI *GEVAPI;
89    
90     #define I_EV_API(YourName) \
91     STMT_START { \
92     SV *sv = perl_get_sv ("EV::API", 0); \
93     if (!sv) croak ("EV::API not found"); \
94 root 1.5 GEVAPI = (struct EVAPI*) SvIV (sv); \
95 root 1.1 if (GEVAPI->ver != EV_API_VERSION \
96     || GEVAPI->rev < EV_API_REVISION) \
97     croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
98     GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
99     } STMT_END
100    
101     #endif
102