From 55f29caf0f13c5da0053e467d844ec0a8a05b8c1 Mon Sep 17 00:00:00 2001 From: Soham Nandy Date: Fri, 11 Apr 2025 02:26:28 +0530 Subject: [PATCH] Revert "refactor: better conditional compilation on time.hpp" This reverts commit 3bb599d35617d1c580e07a01d0fd1097b68a858a. --- src/common/utils/time.hpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/utils/time.hpp b/src/common/utils/time.hpp index 07774107..25236fe0 100644 --- a/src/common/utils/time.hpp +++ b/src/common/utils/time.hpp @@ -4,11 +4,9 @@ #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 @@ -42,10 +40,14 @@ namespace utils /// TODO: find better solution for ARM and Figure out better CPU base frequency heuristics virtual uint64_t timestamp_counter() { -#if defined(ARCH_x86) - return __rdtsc(); -#endif // We are using x86, regardless of compiler the instrinsic is the same +#if defined(_MSC_VER) +#if defined(_M_X64) || defined(_M_AMD64) || defined(_M_IX86) + return __rdtsc(); // 64-bit with MSVC intrinsic +#endif +#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); }