summaryrefslogtreecommitdiff
path: root/ev.c
diff options
context:
space:
mode:
authorroot <root>2008-11-20 00:35:10 +0000
committerroot <root>2008-11-20 00:35:10 +0000
commit04e9dd936bfe30c2121997b1f7ef37b0ac7eb52a (patch)
tree0172e1a3604b0332d83fa1af1e539ab29916d553 /ev.c
parent8c20a0f278301939ecda51c88fa835ea41a0c220 (diff)
*** empty log message ***
Diffstat (limited to 'ev.c')
-rw-r--r--ev.c29
1 files changed, 29 insertions, 0 deletions
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 <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>