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