From 3bb599d35617d1c580e07a01d0fd1097b68a858a Mon Sep 17 00:00:00 2001 From: Soham Nandy Date: Fri, 11 Apr 2025 02:21:22 +0530 Subject: [PATCH] refactor: better conditional compilation on time.hpp --- src/common/utils/time.hpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/common/utils/time.hpp b/src/common/utils/time.hpp index 25236fe0..07774107 100644 --- a/src/common/utils/time.hpp +++ b/src/common/utils/time.hpp @@ -4,9 +4,11 @@ #include "../platform/platform.hpp" #if defined(_MSC_VER) +#define ARCH_x86 #include #pragma intrinsic(__rdtsc) #elif defined(__x86_64__) || defined(__i386__) || defined(__amd64__) +#define ARCH_x86 #include #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((count * 38LL) / 10LL); }