From 04e9dd936bfe30c2121997b1f7ef37b0ac7eb52a Mon Sep 17 00:00:00 2001 From: root Date: Thu, 20 Nov 2008 00:35:10 +0000 Subject: *** empty log message *** --- ev.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'ev.c') diff --git a/ev.c b/ev.c index c872176..538f6a5 100644 --- a/ev.c +++ b/ev.c @@ -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 #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 +# 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 -- cgit v1.2.3