… | |
… | |
284 | |
284 | |
285 | #ifndef EV_HEAP_CACHE_AT |
285 | #ifndef EV_HEAP_CACHE_AT |
286 | # define EV_HEAP_CACHE_AT !EV_MINIMAL |
286 | # define EV_HEAP_CACHE_AT !EV_MINIMAL |
287 | #endif |
287 | #endif |
288 | |
288 | |
289 | /* this block fixes any misconfiguration where we know we run into trouble otherwise */ |
|
|
290 | |
|
|
291 | #ifndef CLOCK_MONOTONIC |
|
|
292 | # undef EV_USE_MONOTONIC |
|
|
293 | # define EV_USE_MONOTONIC 0 |
|
|
294 | #endif |
|
|
295 | |
|
|
296 | #ifndef CLOCK_REALTIME |
|
|
297 | # undef EV_USE_REALTIME |
|
|
298 | # define EV_USE_REALTIME 0 |
|
|
299 | #endif |
|
|
300 | |
|
|
301 | #if !EV_STAT_ENABLE |
|
|
302 | # undef EV_USE_INOTIFY |
|
|
303 | # define EV_USE_INOTIFY 0 |
|
|
304 | #endif |
|
|
305 | |
|
|
306 | #if !EV_USE_NANOSLEEP |
|
|
307 | # ifndef _WIN32 |
|
|
308 | # include <sys/select.h> |
|
|
309 | # endif |
|
|
310 | #endif |
|
|
311 | |
|
|
312 | #if EV_USE_INOTIFY |
|
|
313 | # include <sys/utsname.h> |
|
|
314 | # include <sys/statfs.h> |
|
|
315 | # include <sys/inotify.h> |
|
|
316 | /* some very old inotify.h headers don't have IN_DONT_FOLLOW */ |
|
|
317 | # ifndef IN_DONT_FOLLOW |
|
|
318 | # undef EV_USE_INOTIFY |
|
|
319 | # define EV_USE_INOTIFY 0 |
|
|
320 | # endif |
|
|
321 | #endif |
|
|
322 | |
|
|
323 | #if EV_SELECT_IS_WINSOCKET |
|
|
324 | # include <winsock.h> |
|
|
325 | #endif |
|
|
326 | |
|
|
327 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
289 | /* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ |
328 | /* which makes programs even slower. might work on other unices, too. */ |
290 | /* which makes programs even slower. might work on other unices, too. */ |
329 | #if EV_USE_CLOCK_SYSCALL |
291 | #if EV_USE_CLOCK_SYSCALL |
330 | # include <syscall.h> |
292 | # include <syscall.h> |
331 | # ifdef SYS_clock_gettime |
293 | # ifdef SYS_clock_gettime |
… | |
… | |
336 | # undef EV_USE_CLOCK_SYSCALL |
298 | # undef EV_USE_CLOCK_SYSCALL |
337 | # define EV_USE_CLOCK_SYSCALL 0 |
299 | # define EV_USE_CLOCK_SYSCALL 0 |
338 | # endif |
300 | # endif |
339 | #endif |
301 | #endif |
340 | |
302 | |
|
|
303 | /* this block fixes any misconfiguration where we know we run into trouble otherwise */ |
|
|
304 | |
|
|
305 | #ifndef CLOCK_MONOTONIC |
|
|
306 | # undef EV_USE_MONOTONIC |
|
|
307 | # define EV_USE_MONOTONIC 0 |
|
|
308 | #endif |
|
|
309 | |
|
|
310 | #ifndef CLOCK_REALTIME |
|
|
311 | # undef EV_USE_REALTIME |
|
|
312 | # define EV_USE_REALTIME 0 |
|
|
313 | #endif |
|
|
314 | |
|
|
315 | #if !EV_STAT_ENABLE |
|
|
316 | # undef EV_USE_INOTIFY |
|
|
317 | # define EV_USE_INOTIFY 0 |
|
|
318 | #endif |
|
|
319 | |
|
|
320 | #if !EV_USE_NANOSLEEP |
|
|
321 | # ifndef _WIN32 |
|
|
322 | # include <sys/select.h> |
|
|
323 | # endif |
|
|
324 | #endif |
|
|
325 | |
|
|
326 | #if EV_USE_INOTIFY |
|
|
327 | # include <sys/utsname.h> |
|
|
328 | # include <sys/statfs.h> |
|
|
329 | # include <sys/inotify.h> |
|
|
330 | /* some very old inotify.h headers don't have IN_DONT_FOLLOW */ |
|
|
331 | # ifndef IN_DONT_FOLLOW |
|
|
332 | # undef EV_USE_INOTIFY |
|
|
333 | # define EV_USE_INOTIFY 0 |
|
|
334 | # endif |
|
|
335 | #endif |
|
|
336 | |
|
|
337 | #if EV_SELECT_IS_WINSOCKET |
|
|
338 | # include <winsock.h> |
|
|
339 | #endif |
|
|
340 | |
341 | #if EV_USE_EVENTFD |
341 | #if EV_USE_EVENTFD |
342 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
342 | /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ |
343 | # include <stdint.h> |
343 | # include <stdint.h> |
344 | # ifdef __cplusplus |
344 | # ifdef __cplusplus |
345 | extern "C" { |
345 | extern "C" { |
… | |
… | |
564 | |
564 | |
565 | #endif |
565 | #endif |
566 | |
566 | |
567 | /*****************************************************************************/ |
567 | /*****************************************************************************/ |
568 | |
568 | |
|
|
569 | #ifndef EV_HAVE_EV_TIME |
569 | ev_tstamp |
570 | ev_tstamp |
570 | ev_time (void) |
571 | ev_time (void) |
571 | { |
572 | { |
572 | #if EV_USE_REALTIME |
573 | #if EV_USE_REALTIME |
573 | if (expect_true (have_realtime)) |
574 | if (expect_true (have_realtime)) |
… | |
… | |
580 | |
581 | |
581 | struct timeval tv; |
582 | struct timeval tv; |
582 | gettimeofday (&tv, 0); |
583 | gettimeofday (&tv, 0); |
583 | return tv.tv_sec + tv.tv_usec * 1e-6; |
584 | return tv.tv_sec + tv.tv_usec * 1e-6; |
584 | } |
585 | } |
|
|
586 | #endif |
585 | |
587 | |
586 | inline_size ev_tstamp |
588 | inline_size ev_tstamp |
587 | get_clock (void) |
589 | get_clock (void) |
588 | { |
590 | { |
589 | #if EV_USE_MONOTONIC |
591 | #if EV_USE_MONOTONIC |