… | |
… | |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
30 | */ |
31 | #ifndef _EVENT_H_ |
31 | #ifndef EVENT_H__ |
32 | #define _EVENT_H_ |
32 | #define EVENT_H__ |
33 | |
33 | |
34 | #ifdef EV_H |
34 | #ifdef EV_H |
35 | # include EV_H |
35 | # include EV_H |
36 | #else |
36 | #else |
37 | # include <ev.h> |
37 | # include <ev.h> |
… | |
… | |
40 | #ifdef __cplusplus |
40 | #ifdef __cplusplus |
41 | extern "C" { |
41 | extern "C" { |
42 | #endif |
42 | #endif |
43 | |
43 | |
44 | struct event_base; |
44 | struct event_base; |
|
|
45 | |
|
|
46 | #define EVLIST_TIMEOUT 0x01 |
|
|
47 | #define EVLIST_INSERTED 0x02 |
|
|
48 | #define EVLIST_SIGNAL 0x04 |
|
|
49 | #define EVLIST_ACTIVE 0x08 |
|
|
50 | #define EVLIST_INTERNAL 0x10 |
|
|
51 | #define EVLIST_INIT 0x80 |
45 | |
52 | |
46 | struct event |
53 | struct event |
47 | { |
54 | { |
48 | /* libev watchers we map onto */ |
55 | /* libev watchers we map onto */ |
49 | union { |
56 | union { |
… | |
… | |
57 | void (*ev_callback)(int, short, void *arg); |
64 | void (*ev_callback)(int, short, void *arg); |
58 | void *ev_arg; |
65 | void *ev_arg; |
59 | int ev_fd; |
66 | int ev_fd; |
60 | int ev_pri; |
67 | int ev_pri; |
61 | int ev_res; |
68 | int ev_res; |
|
|
69 | int ev_flags; |
62 | short ev_events; |
70 | short ev_events; |
63 | }; |
71 | }; |
64 | |
72 | |
65 | #define EV_PERSIST 0x10 |
73 | #define EV_PERSIST 0x10 |
66 | |
74 | |
67 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
75 | #define EVENT_SIGNAL(ev) ((int) (ev)->ev_fd) |
68 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
76 | #define EVENT_FD(ev) ((int) (ev)->ev_fd) |
69 | |
77 | |
70 | #define event_initialized(ev) 1 |
78 | #define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT) |
71 | |
79 | |
72 | #define evtimer_add(ev,tv) event_add (ev, tv) |
80 | #define evtimer_add(ev,tv) event_add (ev, tv) |
73 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
81 | #define evtimer_set(ev,cb,data) event_set (ev, -1, 0, cb, data) |
74 | #define evtimer_del(ev) event_del (ev) |
82 | #define evtimer_del(ev) event_del (ev) |
75 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |
83 | #define evtimer_pending(ev,tv) event_pending (ev, EV_TIMEOUT, tv) |