… | |
… | |
30 | */ |
30 | */ |
31 | |
31 | |
32 | #include <stddef.h> |
32 | #include <stddef.h> |
33 | #include <stdlib.h> |
33 | #include <stdlib.h> |
34 | #include <sys/time.h> |
34 | #include <sys/time.h> |
|
|
35 | #include <assert.h> |
35 | |
36 | |
|
|
37 | #include "ev.h" |
36 | #include "event.h" |
38 | #include "event.h" |
37 | |
39 | |
38 | #if EV_MULTIPLICITY |
40 | #if EV_MULTIPLICITY |
39 | # define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base |
41 | # define dLOOPev struct ev_loop *loop = (struct ev_loop *)ev->ev_base |
40 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
42 | # define dLOOPbase struct ev_loop *loop = (struct ev_loop *)base |
… | |
… | |
47 | struct event_base |
49 | struct event_base |
48 | { |
50 | { |
49 | int dummy; |
51 | int dummy; |
50 | }; |
52 | }; |
51 | |
53 | |
52 | static struct event_base x_base, *x_cur; |
54 | static struct event_base *x_cur; |
53 | |
55 | |
54 | static void |
56 | static void |
55 | tv_set (struct timeval *tv, ev_tstamp at) |
57 | tv_set (struct timeval *tv, ev_tstamp at) |
56 | { |
58 | { |
57 | tv->tv_sec = (long)at; |
59 | tv->tv_sec = (long)at; |
… | |
… | |
80 | } |
82 | } |
81 | |
83 | |
82 | void *event_init (void) |
84 | void *event_init (void) |
83 | { |
85 | { |
84 | #if EV_MULTIPLICITY |
86 | #if EV_MULTIPLICITY |
|
|
87 | if (x_cur) |
85 | x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); |
88 | x_cur = (struct event_base *)ev_loop_new (EVMETHOD_AUTO); |
|
|
89 | else |
|
|
90 | x_cur = ev_default_loop (EVMETHOD_AUTO); |
86 | #else |
91 | #else |
87 | x_cur = &x_base; |
92 | assert (("multiple event bases not supported when not compiled with EV_MULTIPLICITY", !x_cur)); |
|
|
93 | |
|
|
94 | x_cur = (struct event_base *)ev_default_loop (EVMETHOD_AUTO); |
88 | #endif |
95 | #endif |
89 | |
96 | |
90 | return x_cur; |
97 | return x_cur; |
91 | } |
98 | } |
92 | |
99 | |