ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/EV/EV/EVAPI.h
Revision: 1.24
Committed: Sat Nov 24 16:12:38 2007 UTC (16 years, 6 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-1_3
Changes since 1.23: +1 -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 int flags; /* cheap on 64 bit systems */ \
17 SV *self; /* contains this struct */ \
18 SV *cb_sv, *fh, *data;
19
20 #ifndef EV_PROTOTYPES
21 # define EV_PROTOTYPES 0
22 #endif
23
24 #define EV_STANDALONE 1
25 #define EV_MULTIPLICITY 0
26
27 #include <ev.h>
28
29 struct EVAPI {
30 I32 ver;
31 I32 rev;
32 #define EV_API_VERSION 1
33 #define EV_API_REVISION 1
34
35 /* perl fh or fd int to fd */
36 int (*sv_fileno) (SV *fh);
37 /* signal number/name to signum */
38 int (*sv_signum) (SV *fh);
39
40 /* same as libev functions */
41 ev_tstamp (*now)(void);
42 ev_tstamp (*(time))(void);
43 unsigned int (*backend)(void);
44 void (*loop)(int flags);
45 void (*unloop)(int how);
46 void (*once)(int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg);
47 void (*io_start)(struct ev_io *);
48 void (*io_stop) (struct ev_io *);
49 void (*timer_start)(struct ev_timer *);
50 void (*timer_stop) (struct ev_timer *);
51 void (*timer_again)(struct ev_timer *);
52 void (*periodic_start)(struct ev_periodic *);
53 void (*periodic_stop) (struct ev_periodic *);
54 void (*signal_start)(struct ev_signal *);
55 void (*signal_stop) (struct ev_signal *);
56 void (*idle_start)(struct ev_idle *);
57 void (*idle_stop) (struct ev_idle *);
58 void (*prepare_start)(struct ev_prepare *);
59 void (*prepare_stop) (struct ev_prepare *);
60 void (*check_start)(struct ev_check *);
61 void (*check_stop) (struct ev_check *);
62 void (*child_start)(struct ev_child *);
63 void (*child_stop) (struct ev_child *);
64 void (*ref)(void);
65 void (*unref)(void);
66 };
67
68 #if !EV_PROTOTYPES
69 # define sv_fileno(sv) GEVAPI->sv_fileno (sv)
70 # define sv_signum(sv) GEVAPI->sv_signum (sv)
71 # define ev_now() GEVAPI->now ()
72 # define ev_time() GEVAPI->(time) ()
73 # define ev_backend() GEVAPI->backend ()
74 # define ev_loop(flags) GEVAPI->loop (flags)
75 # define ev_unloop(how) GEVAPI->unloop (how)
76 # define ev_once(fd,events,timeout,cb,arg) GEVAPI->once ((fd), (events), (timeout), (cb), (arg))
77 # define ev_io_start(w) GEVAPI->io_start (w)
78 # define ev_io_stop(w) GEVAPI->io_stop (w)
79 # define ev_timer_start(w) GEVAPI->timer_start (w)
80 # define ev_timer_stop(w) GEVAPI->timer_stop (w)
81 # define ev_timer_again(w) GEVAPI->timer_again (w)
82 # define ev_periodic_start(w) GEVAPI->periodic_start (w)
83 # define ev_periodic_stop(w) GEVAPI->periodic_stop (w)
84 # define ev_signal_start(w) GEVAPI->signal_start (w)
85 # define ev_signal_stop(w) GEVAPI->signal_stop (w)
86 # define ev_idle_start(w) GEVAPI->idle_start (w)
87 # define ev_idle_stop(w) GEVAPI->idle_stop (w)
88 # define ev_prepare_start(w) GEVAPI->prepare_start (w)
89 # define ev_prepare_stop(w) GEVAPI->prepare_stop (w)
90 # define ev_check_start(w) GEVAPI->check_start (w)
91 # define ev_check_stop(w) GEVAPI->check_stop (w)
92 # define ev_child_start(w) GEVAPI->child_start (w)
93 # define ev_child_stop(w) GEVAPI->child_stop (w)
94 # define ev_ref() GEVAPI->ref ()
95 # define ev_unref() GEVAPI->unref ()
96 #endif
97
98 static struct EVAPI *GEVAPI;
99
100 #define I_EV_API(YourName) \
101 STMT_START { \
102 SV *sv = perl_get_sv ("EV::API", 0); \
103 if (!sv) croak ("EV::API not found"); \
104 GEVAPI = (struct EVAPI*) SvIV (sv); \
105 if (GEVAPI->ver != EV_API_VERSION \
106 || GEVAPI->rev < EV_API_REVISION) \
107 croak ("EV::API version mismatch (%d.%d vs. %d.%d) -- please recompile %s", \
108 GEVAPI->ver, GEVAPI->rev, EV_API_VERSION, EV_API_REVISION, YourName); \
109 } STMT_END
110
111 #endif
112