commit 04a1060: [Minor] Add better support for non-Linux systems
Vsevolod Stakhov
vsevolod at highsecure.ru
Thu Oct 31 13:49:08 UTC 2019
Author: Vsevolod Stakhov
Date: 2019-10-31 13:43:56 +0000
URL: https://github.com/rspamd/rspamd/commit/04a1060f4511dca6b1d8d28f671cb2d8923e04df (HEAD -> master)
[Minor] Add better support for non-Linux systems
---
contrib/libev/ev.c | 21 ++++++++++++++-------
1 file 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
More information about the Commits
mailing list