… | |
… | |
183 | # include EV_H |
183 | # include EV_H |
184 | #else |
184 | #else |
185 | # include "ev.h" |
185 | # include "ev.h" |
186 | #endif |
186 | #endif |
187 | |
187 | |
188 | EV_CPP(extern "C" {) |
|
|
189 | |
|
|
190 | #ifndef _WIN32 |
188 | #ifndef _WIN32 |
191 | # include <sys/time.h> |
189 | # include <sys/time.h> |
192 | # include <sys/wait.h> |
190 | # include <sys/wait.h> |
193 | # include <unistd.h> |
191 | # include <unistd.h> |
194 | #else |
192 | #else |
… | |
… | |
878 | |
876 | |
879 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
877 | #if ECB_MEMORY_FENCE_NEEDS_PTHREADS |
880 | /* if your architecture doesn't need memory fences, e.g. because it is |
878 | /* if your architecture doesn't need memory fences, e.g. because it is |
881 | * single-cpu/core, or if you use libev in a project that doesn't use libev |
879 | * single-cpu/core, or if you use libev in a project that doesn't use libev |
882 | * from multiple threads, then you can define ECB_AVOID_PTHREADS when compiling |
880 | * from multiple threads, then you can define ECB_AVOID_PTHREADS when compiling |
883 | * libev, in which casess the memory fences become nops. |
881 | * libev, in which cases the memory fences become nops. |
884 | * alternatively, you can remove this #error and link against libpthread, |
882 | * alternatively, you can remove this #error and link against libpthread, |
885 | * which will then provide the memory fences. |
883 | * which will then provide the memory fences. |
886 | */ |
884 | */ |
887 | # error "memory fences not defined for your architecture, please report" |
885 | # error "memory fences not defined for your architecture, please report" |
888 | #endif |
886 | #endif |
… | |
… | |
1195 | #undef VAR |
1193 | #undef VAR |
1196 | }; |
1194 | }; |
1197 | #include "ev_wrap.h" |
1195 | #include "ev_wrap.h" |
1198 | |
1196 | |
1199 | static struct ev_loop default_loop_struct; |
1197 | static struct ev_loop default_loop_struct; |
1200 | struct ev_loop *ev_default_loop_ptr; |
1198 | EV_API_DECL struct ev_loop *ev_default_loop_ptr = 0; /* needs to be initialised to make it a definition despite extern */ |
1201 | |
1199 | |
1202 | #else |
1200 | #else |
1203 | |
1201 | |
1204 | ev_tstamp ev_rt_now; |
1202 | EV_API_DECL ev_tstamp ev_rt_now = 0; /* needs to be initialised to make it a definition despite extern */ |
1205 | #define VAR(name,decl) static decl; |
1203 | #define VAR(name,decl) static decl; |
1206 | #include "ev_vars.h" |
1204 | #include "ev_vars.h" |
1207 | #undef VAR |
1205 | #undef VAR |
1208 | |
1206 | |
1209 | static int ev_default_loop_ptr; |
1207 | static int ev_default_loop_ptr; |
… | |
… | |
1303 | |
1301 | |
1304 | do |
1302 | do |
1305 | ncur <<= 1; |
1303 | ncur <<= 1; |
1306 | while (cnt > ncur); |
1304 | while (cnt > ncur); |
1307 | |
1305 | |
1308 | /* if size is large, round to MALLOC_ROUND - 4 * longs to accomodate malloc overhead */ |
1306 | /* if size is large, round to MALLOC_ROUND - 4 * longs to accommodate malloc overhead */ |
1309 | if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) |
1307 | if (elem * ncur > MALLOC_ROUND - sizeof (void *) * 4) |
1310 | { |
1308 | { |
1311 | ncur *= elem; |
1309 | ncur *= elem; |
1312 | ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); |
1310 | ncur = (ncur + elem + (MALLOC_ROUND - 1) + sizeof (void *) * 4) & ~(MALLOC_ROUND - 1); |
1313 | ncur = ncur - sizeof (void *) * 4; |
1311 | ncur = ncur - sizeof (void *) * 4; |
… | |
… | |
2993 | #endif |
2991 | #endif |
2994 | assert ((loop_done = EVBREAK_RECURSE, 1)); /* assert for side effect */ |
2992 | assert ((loop_done = EVBREAK_RECURSE, 1)); /* assert for side effect */ |
2995 | backend_poll (EV_A_ waittime); |
2993 | backend_poll (EV_A_ waittime); |
2996 | assert ((loop_done = EVBREAK_CANCEL, 1)); /* assert for side effect */ |
2994 | assert ((loop_done = EVBREAK_CANCEL, 1)); /* assert for side effect */ |
2997 | |
2995 | |
2998 | pipe_write_wanted = 0; /* just an optimsiation, no fence needed */ |
2996 | pipe_write_wanted = 0; /* just an optimisation, no fence needed */ |
2999 | |
2997 | |
3000 | if (pipe_write_skipped) |
2998 | if (pipe_write_skipped) |
3001 | { |
2999 | { |
3002 | assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w))); |
3000 | assert (("libev: pipe_w not active, but pipe not written", ev_is_active (&pipe_w))); |
3003 | ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); |
3001 | ev_feed_event (EV_A_ &pipe_w, EV_CUSTOM); |
… | |
… | |
4416 | |
4414 | |
4417 | #if EV_MULTIPLICITY |
4415 | #if EV_MULTIPLICITY |
4418 | #include "ev_wrap.h" |
4416 | #include "ev_wrap.h" |
4419 | #endif |
4417 | #endif |
4420 | |
4418 | |
4421 | EV_CPP(}) |
|
|
4422 | |
|
|