aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:34:23 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2017-10-27 11:34:23 +0100
commita8bbbc899c238d06f89a1abe773a967c08051081 (patch)
tree7790f4a8992371c1d017a14cbab809cc9b879ae8 /src/libutil
parentc54eeafdd296585c1bd5100a58a36e3f32d03e78 (diff)
downloadrspamd-a8bbbc899c238d06f89a1abe773a967c08051081.tar.gz
rspamd-a8bbbc899c238d06f89a1abe773a967c08051081.zip
[Fix] Fix ticks processing
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/util.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c
index f022b4689..7cb2ff81a 100644
--- a/src/libutil/util.c
+++ b/src/libutil/util.c
@@ -1792,14 +1792,29 @@ rspamd_get_ticks (gboolean rdtsc_ok)
# endif
clock_gettime (clk_id, &ts);
- res = (double)ts.tv_sec + ts.tv_nsec / 1000000000.;
+ if (rdtsc_ok) {
+ res = (double) ts.tv_sec + ts.tv_nsec / 1000000000.;
+ }
+ else {
+ res = (double) ts.tv_sec * 1e9 + ts.tv_nsec;
+ }
# elif defined(__APPLE__)
- res = mach_absolute_time () / 1000000000.;
+ if (rdtsc_ok) {
+ res = mach_absolute_time ();
+ }
+ else {
+ res = mach_absolute_time () / 1000000000.;
+ }
#else
struct timeval tv;
(void)gettimeofday (&tv, NULL);
- res = (double)tv.tv_sec + tv.tv_usec / 1000000.;
+ if (rdtsc_ok) {
+ res = (double) ts.tv_sec * 1e9 + tv.tv_usec * 1e3;
+ }
+ else {
+ res = (double)tv.tv_sec + tv.tv_usec / 1000000.;
+ }
#endif
return res;