Skip to content

Instantly share code, notes, and snippets.

@bastih
Created July 11, 2012 14:34
Show Gist options
  • Save bastih/3090759 to your computer and use it in GitHub Desktop.
Save bastih/3090759 to your computer and use it in GitHub Desktop.
inline uint64_t rdtsc() {
uint32_t lo, hi;
__asm__ __volatile__ (
"xorl %%eax, %%eax\n"
"cpuid\n"
"rdtsc\n"
: "=a" (lo), "=d" (hi)
:
: "%ebx", "%ecx");
return (uint64_t)hi << 32 | lo;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment