Works fine on MingW32 and CygWin:
#include <stdio.h>
#include <stdint.h>
int main ( void )
{
uint32_t lower = 0, upper = 0;
asm volatile ("rdtsc": "=a" (lower), "=d" (upper));
uint64_t ull = ((uint64_t) upper << 32) + lower;
printf ("%08X %08X\n", upper, lower);
printf ("%llu\n", ull);
return 0;
}
and Visual Studio 2010:
#include <stdio.h>
int main ( void )
{
unsigned _int64 ull = 0;
_asm
{
rdtsc
mov dword ptr ull, eax
mov dword ptr ull+4, edx
}
printf("%I64u\n",ull);
return 0;
}
and this one should work on both Visual Studios, x86 and x64:
#include <stdio.h>
#include <intrin.h>
int main ( void )
{
unsigned _int64 ull = 0;
ull = __rdtsc(); // "Intrinsics"
printf("%I64u\n",ull);
return 0;
}