From: Vsevolod Stakhov Date: Thu, 31 Oct 2019 13:43:56 +0000 (+0000) Subject: [Minor] Add better support for non-Linux systems X-Git-Tag: 2.2~116 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=04a1060f4511dca6b1d8d28f671cb2d8923e04df;p=thirdparty%2Frspamd.git [Minor] Add better support for non-Linux systems --- diff --git a/contrib/libev/ev.c b/contrib/libev/ev.c index c695047310..38438e7456 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