diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-10-27 14:09:40 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-10-27 14:09:40 +0100 |
commit | 48dafdabc1240932db01252279393fdfa18acc14 (patch) | |
tree | 842aa553e32c95efb6211076da699468be9e5624 /src/libutil/util.c | |
parent | a8bbbc899c238d06f89a1abe773a967c08051081 (diff) | |
download | rspamd-48dafdabc1240932db01252279393fdfa18acc14.tar.gz rspamd-48dafdabc1240932db01252279393fdfa18acc14.zip |
[Fix] Another fix for rdtcs
Issue: #1885
Diffstat (limited to 'src/libutil/util.c')
-rw-r--r-- | src/libutil/util.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/libutil/util.c b/src/libutil/util.c index 7cb2ff81a..9c2af41e3 100644 --- a/src/libutil/util.c +++ b/src/libutil/util.c @@ -70,9 +70,11 @@ #ifdef HAVE_SYS_RESOURCE_H #include <sys/resource.h> #endif -#ifdef HAVE_RDTSCP +#ifdef HAVE_RDTSC +#ifdef __x86_64__ #include <x86intrin.h> #endif +#endif #include <math.h> /* for pow */ #include "cryptobox.h" @@ -1768,17 +1770,18 @@ rspamd_get_ticks (gboolean rdtsc_ok) { gdouble res; -#ifdef HAVE_RDTSCP - guint tmp; +#ifdef HAVE_RDTSC +# ifdef __x86_64__ guint64 r64; if (rdtsc_ok) { - r64 = __builtin_ia32_rdtscp (&tmp); + __builtin_ia32_lfence (); + r64 = __rdtsc (); /* Preserve lower 52 bits */ res = r64 & ((1ULL << 53) - 1); return res; } - +# endif #endif #ifdef HAVE_CLOCK_GETTIME struct timespec ts; |