mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-19 03:33:56 +00:00
refactor: better conditional compilation on time.hpp
This commit is contained in:
@@ -4,9 +4,11 @@
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
#if defined(_MSC_VER)
|
||||
#define ARCH_x86
|
||||
#include <intrin.h>
|
||||
#pragma intrinsic(__rdtsc)
|
||||
#elif defined(__x86_64__) || defined(__i386__) || defined(__amd64__)
|
||||
#define ARCH_x86
|
||||
#include <x86intrin.h>
|
||||
#endif
|
||||
|
||||
@@ -40,14 +42,10 @@ namespace utils
|
||||
/// TODO: find better solution for ARM and Figure out better CPU base frequency heuristics
|
||||
virtual uint64_t timestamp_counter()
|
||||
{
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86)
|
||||
return __rdtsc(); // 64-bit with MSVC intrinsic
|
||||
#endif
|
||||
#if defined(ARCH_x86)
|
||||
return __rdtsc();
|
||||
#endif // We are using x86, regardless of compiler the instrinsic is the same
|
||||
|
||||
#elif defined(__x86_64__) || defined(__i386__) || defined(__amd64__) // If we are using clang or gcc
|
||||
return __rdtsc(); // 64-bit with clang/gcc intrinsic
|
||||
#endif
|
||||
int64_t count = std::chrono::high_resolution_clock::now().time_since_epoch().count();
|
||||
return static_cast<uint64_t>((count * 38LL) / 10LL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user