1 /** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 7 #include <intrin.h> 8 9 /* Clang has support for MSVC builtins, GCC doesn't */ 10 #ifndef __has_builtin 11 #define __has_builtin(x) 0 12 #endif 13 14 #if !__has_builtin(__rdtsc) __rdtsc(void)15unsigned __int64 __rdtsc(void) 16 { 17 #ifdef _WIN64 18 unsigned __int64 val1, val2; 19 #else 20 unsigned int val1, val2; 21 #endif 22 __asm__ __volatile__ ( 23 "rdtsc" 24 : "=a" (val1), "=d" (val2)); 25 return ((unsigned __int64)val1) | (((unsigned __int64)val2) << 32); 26 } 27 #endif 28