diff options
Diffstat (limited to 'ev.c')
-rw-r--r-- | ev.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -49,6 +49,18 @@ extern "C" { # include "config.h" # endif +# if HAVE_CLOCK_SYSCALL +# ifndef EV_USE_CLOCK_SYSCALL +# define EV_USE_CLOCK_SYSCALL 1 +# ifndef EV_USE_REALTIME +# define EV_USE_REALTIME 0 +# endif +# ifndef EV_USE_MONOTONIC +# define EV_USE_MONOTONIC 1 +# endif +# endif +# endif + # if HAVE_CLOCK_GETTIME # ifndef EV_USE_MONOTONIC # define EV_USE_MONOTONIC 1 @@ -166,6 +178,14 @@ extern "C" { /* this block tries to deduce configuration from header-defined symbols and defaults */ +#ifndef EV_USE_CLOCK_SYSCALL +# if __linux && __GLIBC__ >= 2 +# define EV_USE_CLOCK_SYSCALL 1 +# else +# define EV_USE_CLOCK_SYSCALL 0 +# endif +#endif + #ifndef EV_USE_MONOTONIC # if defined (_POSIX_MONOTONIC_CLOCK) && _POSIX_MONOTONIC_CLOCK >= 0 # define EV_USE_MONOTONIC 1 @@ -302,6 +322,15 @@ extern "C" { # include <winsock.h> #endif +/* on linux, we can use a (slow) syscall to avoid a dependency on pthread, */ +/* which makes programs even slower. might work on other unices, too. */ +#if EV_USE_CLOCK_SYSCALL +# include <syscall.h> +# define clock_gettime(id, ts) syscall (SYS_clock_gettime, (id), (ts)) +# undef EV_USE_MONOTONIC +# define EV_USE_MONOTONIC 1 +#endif + #if EV_USE_EVENTFD /* our minimum requirement is glibc 2.7 which has the stub, but not the header */ # include <stdint.h> |