diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-31 13:43:56 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2019-10-31 13:43:56 +0000 |
commit | 04a1060f4511dca6b1d8d28f671cb2d8923e04df (patch) | |
tree | c02ae7f4a6154eeed067a0e9eef798fbc81c3a21 /contrib | |
parent | 0c75651fafc4713429df31ca69bb665ee0b3ce9d (diff) | |
download | rspamd-04a1060f4511dca6b1d8d28f671cb2d8923e04df.tar.gz rspamd-04a1060f4511dca6b1d8d28f671cb2d8923e04df.zip |
[Minor] Add better support for non-Linux systems
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libev/ev.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/contrib/libev/ev.c b/contrib/libev/ev.c index c69504731..38438e745 100644 --- a/contrib/libev/ev.c +++ b/contrib/libev/ev.c @@ -2893,15 +2893,22 @@ loop_init (EV_P_ unsigned int flags) EV_NOEXCEPT if (!clock_gettime (CLOCK_MONOTONIC, &ts)) { have_monotonic = 1; monotinic_clock_id = CLOCK_MONOTONIC; +#define CHECK_CLOCK_SOURCE(id) do { \ + if (!clock_gettime ((id), &ts) && \ + !clock_getres ((id), &ts)) { \ + if (ts.tv_sec == 0 && ts.tv_nsec < 10ULL * 1000000) { \ + monotinic_clock_id = (id); \ + } \ + } \ +} while(0) #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; - } - } + CHECK_CLOCK_SOURCE(CLOCK_MONOTONIC_COARSE); +#elif defined(CLOCK_MONOTONIC_FAST) /* BSD stuff */ + CHECK_CLOCK_SOURCE(CLOCK_MONOTONIC_FAST); +#elif defined(CLOCK_MONOTONIC_RAW_APPROX) /* OSX stuff */ + CHECK_CLOCK_SOURCE(CLOCK_MONOTONIC_RAW_APPROX); #endif +#undef CHECK_CLOCK_SOURCE } } #endif |