ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.10
Committed: Thu Nov 1 06:48:49 2007 UTC (16 years, 7 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.9: +17 -17 lines
Log Message:
the big rename

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.9 void (*child_start)(struct ev_child *);
61     void (*child_stop) (struct ev_child *);
62 root 1.1 };
63    
64 root 1.7 #if !EV_PROTOTYPES
65     # define sv_fileno(sv) GEVAPI->sv_fileno (sv)
66     # define sv_signum(sv) GEVAPI->sv_signum (sv)
67     # define ev_now *GEVAPI->now
68     # define ev_method *GEVAPI->method
69     # define ev_loop_done *GEVAPI->loop_done
70     # define ev_time() GEVAPI->(time)()
71     # define ev_loop(flags) GEVAPI->loop (flags)
72     # define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg))
73 root 1.10 # define ev_io_start(w) GEVAPI->io_start (w)
74     # define ev_io_stop(w) GEVAPI->io_stop (w)
75     # define ev_timer_start(w) GEVAPI->timer_start (w)
76     # define ev_timer_stop(w) GEVAPI->timer_stop (w)
77     # define ev_timer_again(w) GEVAPI->timer_again (w)
78     # define ev_periodic_start(w) GEVAPI->periodic_start (w)
79     # define ev_periodic_stop(w) GEVAPI->periodic_stop (w)
80     # define ev_signal_start(w) GEVAPI->signal_start (w)
81     # define ev_signal_stop(w) GEVAPI->signal_stop (w)
82     # define ev_idle_start(w) GEVAPI->idle_start (w)
83     # define ev_idle_stop(w) GEVAPI->idle_stop (w)
84     # define ev_prepare_start(w) GEVAPI->prepare_start (w)
85     # define ev_prepare_stop(w) GEVAPI->prepare_stop (w)
86     # define ev_check_start(w) GEVAPI->check_start (w)
87     # define ev_check_stop(w) GEVAPI->check_stop (w)
88     # define ev_child_start(w) GEVAPI->child_start (w)
89     # define ev_child_stop(w) GEVAPI->child_stop (w)
90 root 1.7 #endif
91 root 1.2
92 root 1.1 static struct EVAPI *GEVAPI;
93    
94     #define I_EV_API(YourName) \
95     STMT_START { \
96     SV *sv = perl_get_sv ("EV::API", 0); \
97     if (!sv) croak ("EV::API not found"); \
98 root 1.5 GEVAPI = (struct EVAPI*) SvIV (sv); \
99 root 1.1 if (GEVAPI->ver != EV_API_VERSION \
100     || GEVAPI->rev < EV_API_REVISION) \
101     croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
102     GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
103     } STMT_END
104    
105     #endif
106