Commit 0b7fa5a0 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent 042fc295
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment