… | |
… | |
145 | # include <sys/types.h> |
145 | # include <sys/types.h> |
146 | # endif |
146 | # endif |
147 | # include <sys/stat.h> |
147 | # include <sys/stat.h> |
148 | #endif |
148 | #endif |
149 | |
149 | |
|
|
150 | /* in C++ we can use this to provide default arguments */ |
150 | #ifdef __cplusplus |
151 | #ifdef __cplusplus |
151 | # define EV_DEFARG(x) = x |
152 | # define EV_DEFARG(x) = x |
152 | #else |
153 | #else |
153 | # define EV_DEFARG(x) |
154 | # define EV_DEFARG(x) |
154 | #endif |
155 | #endif |
155 | |
156 | |
156 | /* support multiple event loops? */ |
157 | /* support multiple event loops? */ |
157 | #if EV_MULTIPLICITY |
158 | #if EV_MULTIPLICITY |
158 | struct ev_loop; |
159 | struct ev_loop; |
159 | # define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */ |
160 | # define EV_P struct ev_loop *loop /* a loop as sole parameter in a declaration */ |
160 | # define EV_P_ EV_P, /* a loop as first of multiple parameters */ |
161 | # define EV_P_ EV_P, /* a loop as first of multiple parameters */ |
161 | # define EV_A loop /* a loop as sole argument to a function call */ |
162 | # define EV_A loop /* a loop as sole argument to a function call */ |
162 | # define EV_A_ EV_A, /* a loop as first of multiple arguments */ |
163 | # define EV_A_ EV_A, /* a loop as first of multiple arguments */ |
163 | # define EV_DEFAULT_UC ev_default_loop_uc () /* the default loop, if initialised, as sole arg */ |
164 | # define EV_DEFAULT_UC ev_default_loop_uc () /* the default loop, if initialised, as sole arg */ |
164 | # define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */ |
165 | # define EV_DEFAULT_UC_ EV_DEFAULT_UC, /* the default loop as first of multiple arguments */ |
165 | # define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */ |
166 | # define EV_DEFAULT ev_default_loop (0) /* the default loop as sole arg */ |
166 | # define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */ |
167 | # define EV_DEFAULT_ EV_DEFAULT, /* the default loop as first of multiple arguments */ |
167 | # define EV_PDEF EV_P EV_DEFARG (EV_DEFAULT_UC) /* EV_P, but with default argument in C++ */ |
168 | # define EV_PDEF EV_P EV_DEFARG (EV_DEFAULT_UC) /* EV_P, but with default argument in C++ */ |
|
|
169 | # define EV_PDEF_ EV_P EV_DEFARG (EV_DEFAULT_UC), /* EV_P_, but with default argument in C++ */ |
168 | #else |
170 | #else |
169 | # define EV_P void |
171 | # define EV_P void |
170 | # define EV_P_ |
172 | # define EV_P_ |
171 | # define EV_A |
173 | # define EV_A |
172 | # define EV_A_ |
174 | # define EV_A_ |
173 | # define EV_DEFAULT |
175 | # define EV_DEFAULT |
174 | # define EV_DEFAULT_ |
176 | # define EV_DEFAULT_ |
175 | # define EV_DEFAULT_UC |
177 | # define EV_DEFAULT_UC |
176 | # define EV_DEFAULT_UC_ |
178 | # define EV_DEFAULT_UC_ |
177 | # define EV_PDEF EV_P |
179 | # define EV_PDEF EV_P |
|
|
180 | # define EV_PDEF_ EV_P_ |
178 | # undef EV_EMBED_ENABLE |
181 | # undef EV_EMBED_ENABLE |
179 | #endif |
182 | #endif |
180 | |
183 | |
|
|
184 | /* EV_INLINE is used for functions in header files */ |
181 | #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 |
185 | #if __STDC_VERSION__ >= 199901L || __GNUC__ >= 3 |
182 | # define EV_INLINE static inline |
186 | # define EV_INLINE static inline |
183 | #else |
187 | #else |
184 | # define EV_INLINE static |
188 | # define EV_INLINE static |
185 | #endif |
189 | #endif |
186 | |
190 | |
|
|
191 | /* EV_PROTOTYPES can be sued to switch of prototype declarations */ |
187 | #ifndef EV_PROTOTYPES |
192 | #ifndef EV_PROTOTYPES |
188 | # define EV_PROTOTYPES 1 |
193 | # define EV_PROTOTYPES 1 |
189 | #endif |
194 | #endif |
190 | |
195 | |
191 | /*****************************************************************************/ |
196 | /*****************************************************************************/ |
… | |
… | |
601 | EVBREAK_ONE = 1, /* unloop once */ |
606 | EVBREAK_ONE = 1, /* unloop once */ |
602 | EVBREAK_ALL = 2 /* unloop all loops */ |
607 | EVBREAK_ALL = 2 /* unloop all loops */ |
603 | }; |
608 | }; |
604 | |
609 | |
605 | #if EV_PROTOTYPES |
610 | #if EV_PROTOTYPES |
606 | void ev_run (EV_P_ int flags EV_DEFARG (0)); |
611 | void ev_run (EV_PDEF_ int flags EV_DEFARG (0)); |
607 | void ev_break (EV_P_ int how EV_DEFARG (EVBREAK_ONE)); /* break out of the loop */ |
612 | void ev_break (EV_PDEF_ int how EV_DEFARG (EVBREAK_ONE)); /* break out of the loop */ |
608 | |
613 | |
609 | /* |
614 | /* |
610 | * ref/unref can be used to add or remove a refcount on the mainloop. every watcher |
615 | * ref/unref can be used to add or remove a refcount on the mainloop. every watcher |
611 | * keeps one reference. if you have a long-running watcher you never unregister that |
616 | * keeps one reference. if you have a long-running watcher you never unregister that |
612 | * should not keep ev_loop from running, unref() after starting, and ref() before stopping. |
617 | * should not keep ev_loop from running, unref() after starting, and ref() before stopping. |