… | |
… | |
45 | #endif |
45 | #endif |
46 | |
46 | |
47 | /*****************************************************************************/ |
47 | /*****************************************************************************/ |
48 | |
48 | |
49 | #ifndef EV_FEATURES |
49 | #ifndef EV_FEATURES |
50 | # define EV_FEATURES 0x3f |
50 | # define EV_FEATURES 0x7f |
51 | #endif |
51 | #endif |
52 | |
52 | |
53 | #define EV_FEATURE_CODE ((EV_FEATURES) & 1) |
53 | #define EV_FEATURE_CODE ((EV_FEATURES) & 1) |
54 | #define EV_FEATURE_DATA ((EV_FEATURES) & 2) |
54 | #define EV_FEATURE_DATA ((EV_FEATURES) & 2) |
|
|
55 | #define EV_FEATURE_CONFIG ((EV_FEATURES) & 4) |
55 | #define EV_FEATURE_API ((EV_FEATURES) & 4) |
56 | #define EV_FEATURE_API ((EV_FEATURES) & 8) |
56 | #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 8) |
57 | #define EV_FEATURE_WATCHERS ((EV_FEATURES) & 16) |
57 | #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 16) |
58 | #define EV_FEATURE_BACKENDS ((EV_FEATURES) & 32) |
58 | #define EV_FEATURE_OS ((EV_FEATURES) & 32) |
59 | #define EV_FEATURE_OS ((EV_FEATURES) & 64) |
59 | |
60 | |
60 | /* these priorities are inclusive, higher priorities will be called earlier */ |
61 | /* these priorities are inclusive, higher priorities will be invoked earlier */ |
61 | #ifndef EV_MINPRI |
62 | #ifndef EV_MINPRI |
62 | # define EV_MINPRI (EV_FEATURE_API ? -2 : 0) |
63 | # define EV_MINPRI (EV_FEATURE_CONFIG ? -2 : 0) |
63 | #endif |
64 | #endif |
64 | #ifndef EV_MAXPRI |
65 | #ifndef EV_MAXPRI |
65 | # define EV_MAXPRI (EV_FEATURE_API ? +2 : 0) |
66 | # define EV_MAXPRI (EV_FEATURE_CONFIG ? +2 : 0) |
66 | #endif |
67 | #endif |
67 | |
68 | |
68 | #ifndef EV_MULTIPLICITY |
69 | #ifndef EV_MULTIPLICITY |
69 | # define EV_MULTIPLICITY EV_FEATURE_API |
70 | # define EV_MULTIPLICITY EV_FEATURE_CONFIG |
70 | #endif |
71 | #endif |
71 | |
72 | |
72 | #ifndef EV_PERIODIC_ENABLE |
73 | #ifndef EV_PERIODIC_ENABLE |
73 | # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS |
74 | # define EV_PERIODIC_ENABLE EV_FEATURE_WATCHERS |
74 | #endif |
75 | #endif |
… | |
… | |
168 | # define EV_INLINE static inline |
169 | # define EV_INLINE static inline |
169 | #else |
170 | #else |
170 | # define EV_INLINE static |
171 | # define EV_INLINE static |
171 | #endif |
172 | #endif |
172 | |
173 | |
|
|
174 | #ifndef EV_PROTOTYPES |
|
|
175 | # define EV_PROTOTYPES 1 |
|
|
176 | #endif |
|
|
177 | |
173 | /*****************************************************************************/ |
178 | /*****************************************************************************/ |
|
|
179 | |
|
|
180 | #define EV_VERSION_MAJOR 4 |
|
|
181 | #define EV_VERSION_MINOR 0 |
174 | |
182 | |
175 | /* eventmask, revents, events... */ |
183 | /* eventmask, revents, events... */ |
176 | #define EV_UNDEF -1 /* guaranteed to be invalid */ |
184 | #define EV_UNDEF -1 /* guaranteed to be invalid */ |
177 | #define EV_NONE 0x00 /* no events */ |
185 | #define EV_NONE 0x00 /* no events */ |
178 | #define EV_READ 0x01 /* ev_io detected read will not block */ |
186 | #define EV_READ 0x01 /* ev_io detected read will not block */ |
179 | #define EV_WRITE 0x02 /* ev_io detected write will not block */ |
187 | #define EV_WRITE 0x02 /* ev_io detected write will not block */ |
180 | #define EV__IOFDSET 0x80 /* internal use only */ |
188 | #define EV__IOFDSET 0x80 /* internal use only */ |
181 | #define EV_IO EV_READ /* alias for type-detection */ |
189 | #define EV_IO EV_READ /* alias for type-detection */ |
182 | #define EV_TIMEOUT 0x00000100 /* timer timed out */ |
190 | #define EV_TIMER 0x00000100 /* timer timed out */ |
183 | #define EV_TIMER EV_TIMEOUT /* alias for type-detection */ |
191 | #define EV_TIMEOUT EV_TIMER /* pre 4.0 API compatibility */ |
184 | #define EV_PERIODIC 0x00000200 /* periodic timer timed out */ |
192 | #define EV_PERIODIC 0x00000200 /* periodic timer timed out */ |
185 | #define EV_SIGNAL 0x00000400 /* signal was received */ |
193 | #define EV_SIGNAL 0x00000400 /* signal was received */ |
186 | #define EV_CHILD 0x00000800 /* child/pid had status change */ |
194 | #define EV_CHILD 0x00000800 /* child/pid had status change */ |
187 | #define EV_STAT 0x00001000 /* stat data changed */ |
195 | #define EV_STAT 0x00001000 /* stat data changed */ |
188 | #define EV_IDLE 0x00002000 /* event loop is idling */ |
196 | #define EV_IDLE 0x00002000 /* event loop is idling */ |
… | |
… | |
196 | |
204 | |
197 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
205 | /* can be used to add custom fields to all watchers, while losing binary compatibility */ |
198 | #ifndef EV_COMMON |
206 | #ifndef EV_COMMON |
199 | # define EV_COMMON void *data; |
207 | # define EV_COMMON void *data; |
200 | #endif |
208 | #endif |
201 | #ifndef EV_PROTOTYPES |
|
|
202 | # define EV_PROTOTYPES 1 |
|
|
203 | #endif |
|
|
204 | |
|
|
205 | #define EV_VERSION_MAJOR 3 |
|
|
206 | #define EV_VERSION_MINOR 9 |
|
|
207 | |
209 | |
208 | #ifndef EV_CB_DECLARE |
210 | #ifndef EV_CB_DECLARE |
209 | # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents); |
211 | # define EV_CB_DECLARE(type) void (*cb)(EV_P_ struct type *w, int revents); |
210 | #endif |
212 | #endif |
211 | #ifndef EV_CB_INVOKE |
213 | #ifndef EV_CB_INVOKE |
212 | # define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents)) |
214 | # define EV_CB_INVOKE(watcher,revents) (watcher)->cb (EV_A_ (watcher), (revents)) |
213 | #endif |
215 | #endif |
|
|
216 | |
|
|
217 | /* not official, do not use */ |
|
|
218 | #define EV_CB(type,name) void name (EV_P_ struct ev_ ## type *w, int revents) |
214 | |
219 | |
215 | /* |
220 | /* |
216 | * struct member types: |
221 | * struct member types: |
217 | * private: you may look at them, but not change them, |
222 | * private: you may look at them, but not change them, |
218 | * and they might not mean anything to you. |
223 | * and they might not mean anything to you. |
… | |
… | |
229 | * or the array index + 1 in the pendings array. |
234 | * or the array index + 1 in the pendings array. |
230 | */ |
235 | */ |
231 | |
236 | |
232 | #if EV_MINPRI == EV_MAXPRI |
237 | #if EV_MINPRI == EV_MAXPRI |
233 | # define EV_DECL_PRIORITY |
238 | # define EV_DECL_PRIORITY |
234 | #else |
239 | #elif !defined (EV_DECL_PRIORITY) |
235 | # define EV_DECL_PRIORITY int priority; |
240 | # define EV_DECL_PRIORITY int priority; |
236 | #endif |
241 | #endif |
237 | |
242 | |
238 | /* shared by all watchers */ |
243 | /* shared by all watchers */ |
239 | #define EV_WATCHER(type) \ |
244 | #define EV_WATCHER(type) \ |
… | |
… | |
583 | * if timeout is < 0, do wait indefinitely |
588 | * if timeout is < 0, do wait indefinitely |
584 | */ |
589 | */ |
585 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
590 | void ev_once (EV_P_ int fd, int events, ev_tstamp timeout, void (*cb)(int revents, void *arg), void *arg); |
586 | |
591 | |
587 | # if EV_FEATURE_API |
592 | # if EV_FEATURE_API |
588 | unsigned int ev_loop_count (EV_P); /* number of loop iterations */ |
593 | unsigned int ev_iteration (EV_P); /* number of loop iterations */ |
589 | unsigned int ev_loop_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ |
594 | unsigned int ev_depth (EV_P); /* #ev_loop enters - #ev_loop leaves */ |
590 | void ev_loop_verify (EV_P); /* abort if loop data corrupted */ |
595 | void ev_verify (EV_P); /* abort if loop data corrupted */ |
|
|
596 | |
|
|
597 | /* pre 4.0 API compatibility */ |
|
|
598 | # if EV_MULTIPLICITY |
|
|
599 | # define ev_loop_count(l) ev_iteration (l) |
|
|
600 | # define ev_loop_depth(l) ev_depth (l) |
|
|
601 | # define ev_loop_verify(l) ev_verify (l) |
|
|
602 | # endif |
591 | |
603 | |
592 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
604 | void ev_set_io_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
593 | void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
605 | void ev_set_timeout_collect_interval (EV_P_ ev_tstamp interval); /* sleep at least this time, default 0 */ |
594 | |
606 | |
595 | /* advanced stuff for threading etc. support, see docs */ |
607 | /* advanced stuff for threading etc. support, see docs */ |