aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libev
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-31 13:19:06 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-10-31 13:19:06 +0000
commit0c75651fafc4713429df31ca69bb665ee0b3ce9d (patch)
tree4a954d62b7c30ce20bc529edcde26a0ec4bc8682 /contrib/libev
parenta35e93dc39223107941a5b31ed6d0191e27777b4 (diff)
downloadrspamd-0c75651fafc4713429df31ca69bb665ee0b3ce9d.tar.gz
rspamd-0c75651fafc4713429df31ca69bb665ee0b3ce9d.zip
[Minor] Use CLOCK_MONOTONIC_COARSE where suitable
Diffstat (limited to 'contrib/libev')
-rw-r--r--contrib/libev/ev.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/contrib/libev/ev.c b/contrib/libev/ev.c
index 82d2fa8a9..c69504731 100644
--- a/contrib/libev/ev.c
+++ b/contrib/libev/ev.c
@@ -1570,6 +1570,7 @@ static EV_ATOMIC_T have_realtime; /* did clock_gettime (CLOCK_REALTIME) work? */
#if EV_USE_MONOTONIC
static EV_ATOMIC_T have_monotonic; /* did clock_gettime (CLOCK_MONOTONIC) work? */
+static EV_ATOMIC_T monotinic_clock_id;
#endif
#ifndef EV_FD_TO_WIN32_HANDLE
@@ -1892,7 +1893,7 @@ get_clock (void)
if (expect_true (have_monotonic))
{
struct timespec ts;
- clock_gettime (CLOCK_MONOTONIC, &ts);
+ clock_gettime (monotinic_clock_id, &ts);
return ts.tv_sec + ts.tv_nsec * 1e-9;
}
#endif
@@ -2889,8 +2890,19 @@ loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT
{
struct timespec ts;
- if (!clock_gettime (CLOCK_MONOTONIC, &ts))
+ if (!clock_gettime (CLOCK_MONOTONIC, &ts)) {
have_monotonic = 1;
+ monotinic_clock_id = CLOCK_MONOTONIC;
+#ifdef CLOCK_MONOTONIC_COARSE
+ if (!clock_gettime (CLOCK_MONOTONIC_COARSE, &ts) &&
+ !clock_getres (CLOCK_MONOTONIC_COARSE, &ts)) {
+ /* Check if we have at least 10ms resolution */
+ if (ts.tv_sec == 0 && ts.tv_nsec < 10ULL * 1000000) {
+ monotinic_clock_id = CLOCK_MONOTONIC_COARSE;
+ }
+ }
+#endif
+ }
}
#endif