Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Timing/timestamp.h')
-rw-r--r--Source/Timing/timestamp.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/Source/Timing/timestamp.h b/Source/Timing/timestamp.h
index 12576f6c..f579b389 100644
--- a/Source/Timing/timestamp.h
+++ b/Source/Timing/timestamp.h
@@ -27,17 +27,21 @@
#include <Compat/platform.h>
inline uint64_t GetTimestamp() {
- // Use rdtsc instruction to get the tsc or Time Stamp Counter
+ // Use rdtsc instruction to get the tsc or Time Stamp Counter
#if (defined(PLATFORM_LINUX) || defined(PLATFORM_MACOSX)) && (defined(__i386__) || defined(__x86_64__))
- uint32_t rax, rdx;
- asm volatile ( "lfence" ::: "memory" ); //Fence memory load to everything is executed up to this point.
- asm volatile ( "rdtsc\n" : "=a" (rax), "=d" (rdx) : : );
- return ((uint64_t)rdx << 32) + rax;
-#elif defined(PLATFORM_WINDOWS) && _MSC_VER >= 1600
- unsigned __int64 i;
- _ReadBarrier();
- i = __rdtsc();
- return (uint64_t)i;
+ uint32_t rax, rdx;
+ asm volatile("lfence" ::
+ : "memory"); // Fence memory load to everything is executed up to this point.
+ asm volatile("rdtsc\n"
+ : "=a"(rax), "=d"(rdx)
+ :
+ :);
+ return ((uint64_t)rdx << 32) + rax;
+#elif defined(PLATFORM_WINDOWS) && _MSC_VER >= 1600
+ unsigned __int64 i;
+ _ReadBarrier();
+ i = __rdtsc();
+ return (uint64_t)i;
#else
#error "No timer implementation for current target platform"