ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.16
Committed: Tue Nov 6 16:09:37 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-0_5, rel-0_51
Changes since 1.15: +1 -1 lines
Log Message:
big win32 check-in

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 root 1.16 SV *cb_sv, *fh
18 root 1.7
19     #ifndef EV_PROTOTYPES
20     # define EV_PROTOTYPES 0
21     #endif
22    
23 root 1.14 #define EV_STANDALONE 1
24 root 1.12 #define EV_MULTIPLICITY 0
25    
26 root 1.4 #include <ev.h>
27 root 1.1
28     struct EVAPI {
29     I32 ver;
30     I32 rev;
31 root 1.8 #define EV_API_VERSION 1
32 root 1.1 #define EV_API_REVISION 0
33    
34 root 1.4 /* 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 root 1.11 ev_tstamp (*now)(void);
41 root 1.4 ev_tstamp (*(time))(void);
42 root 1.12 int (*method)(void);
43 root 1.4 void (*loop)(int flags);
44 root 1.11 void (*unloop)(int how);
45 root 1.7 void (*once)(int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
46 root 1.4 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 root 1.6 void (*timer_again)(struct ev_timer *);
51 root 1.4 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 root 1.8 void (*prepare_start)(struct ev_prepare *);
58     void (*prepare_stop) (struct ev_prepare *);
59 root 1.4 void (*check_start)(struct ev_check *);
60     void (*check_stop) (struct ev_check *);
61 root 1.9 void (*child_start)(struct ev_child *);
62     void (*child_stop) (struct ev_child *);
63 root 1.1 };
64    
65 root 1.7 #if !EV_PROTOTYPES
66     # define sv_fileno(sv) GEVAPI->sv_fileno (sv)
67     # define sv_signum(sv) GEVAPI->sv_signum (sv)
68 root 1.11 # define ev_now() GEVAPI->now ()
69     # define ev_time() GEVAPI->(time) ()
70     # define ev_method() GEVAPI->method ()
71 root 1.7 # define ev_loop(flags) GEVAPI->loop (flags)
72 root 1.11 # define ev_unloop() GEVAPI->unloop (int how)
73 root 1.7 # define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg))
74 root 1.10 # 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 root 1.7 #endif
92 root 1.2
93 root 1.1 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 root 1.5 GEVAPI = (struct EVAPI*) SvIV (sv); \
100 root 1.1 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