mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-12-04 17:24:47 +00:00
Changed: Use __rdtsc() intrinsics everywhere for Intel CPUs
This commit is contained in:
parent
b0da68f0d6
commit
acb0a5303a
1 changed files with 6 additions and 14 deletions
|
@ -38,6 +38,10 @@
|
||||||
# include <sys/types.h>
|
# include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(NL_CPU_INTEL) && defined(NL_COMP_GCC)
|
||||||
|
#include "x86intrin.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "string_common.h"
|
#include "string_common.h"
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
|
@ -65,20 +69,8 @@ namespace NLMISC
|
||||||
|
|
||||||
inline uint64 rdtsc()
|
inline uint64 rdtsc()
|
||||||
{
|
{
|
||||||
uint64 ticks;
|
// __rdtsc() is defined under all platforms
|
||||||
# ifdef NL_OS_WINDOWS
|
return uint64(__rdtsc());
|
||||||
# ifdef NL_NO_ASM
|
|
||||||
ticks = uint64(__rdtsc());
|
|
||||||
# else
|
|
||||||
// We should use the intrinsic code now. ticks = uint64(__rdtsc());
|
|
||||||
__asm rdtsc
|
|
||||||
__asm mov DWORD PTR [ticks], eax
|
|
||||||
__asm mov DWORD PTR [ticks + 4], edx
|
|
||||||
# endif // NL_NO_ASM
|
|
||||||
# else
|
|
||||||
__asm__ volatile(".byte 0x0f, 0x31" : "=a" (ticks.low), "=d" (ticks.high));
|
|
||||||
# endif // NL_OS_WINDOWS
|
|
||||||
return ticks;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // NL_CPU_INTEL
|
#endif // NL_CPU_INTEL
|
||||||
|
|
Loading…
Reference in a new issue