diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2019-06-27 12:19:51 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2019-06-27 12:19:51 +0300 |
commit | 0b7fa5a05deecaf52207f00bb02b5c6b460abb11 (patch) | |
tree | 8152f2d9c017300dc814adb68a4e00e1167348ba /mysys | |
parent | 042fc2959705eba79b2eae6031d5f9ca5c454c01 (diff) | |
download | mariadb-git-0b7fa5a05deecaf52207f00bb02b5c6b460abb11.tar.gz |
MDEV-19845: Fix the build on some x86 targets
The RDTSC instruction, which was introduced in the Intel Pentium,
has been used in MariaDB for a long time. But, the __rdtsc()
wrapper is not available by default in some x86 build environments.
The simplest solution seems to replace the inlined instruction
with a call to the wrapper function my_timer_cycles(). The overhead
for the call should not affect the measurement threshold.
On Windows and on AMD64, we will keep using __rdtsc() directly.
Diffstat (limited to 'mysys')
-rw-r--r-- | mysys/my_cpu.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/mysys/my_cpu.c b/mysys/my_cpu.c index cd13624df0f..dd8ff4b6a02 100644 --- a/mysys/my_cpu.c +++ b/mysys/my_cpu.c @@ -24,8 +24,15 @@ unsigned my_cpu_relax_multiplier = 200; # ifdef _MSC_VER # include <intrin.h> +# define my_timer_cycles __rdtsc +# elif !defined __x86_64__ +/* On some x86 targets, __rdtsc() causes an unresolved external symbol error, +instead of being inlined. Let us fall back to my_timer_cycles(), which +internally invokes rdtsc. */ +# include <my_rdtsc.h> # else # include <x86intrin.h> +# define my_timer_cycles __rdtsc # endif #define PAUSE4 MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU(); MY_RELAX_CPU() @@ -70,11 +77,11 @@ unsigned my_cpu_relax_multiplier = 200; void my_cpu_init(void) { uint64_t t0, t1, t2; - t0= __rdtsc(); + t0= my_timer_cycles(); PAUSE16; - t1= __rdtsc(); + t1= my_timer_cycles(); PAUSE16; - t2= __rdtsc(); + t2= my_timer_cycles(); if (t2 - t1 > 30 * 16 && t1 - t0 > 30 * 16) my_cpu_relax_multiplier= 20; } |