Skip to content

Instantly share code, notes, and snippets.

@noushi
Created November 26, 2022 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noushi/e92c35d6142608ec8452e1a1f36564f0 to your computer and use it in GitHub Desktop.
Save noushi/e92c35d6142608ec8452e1a1f36564f0 to your computer and use it in GitHub Desktop.
#define USE_RDTSC 1

static inline unsigned long long rdtsc(void) {
    unsigned long long r;
    __asm__ __volatile__ ("rdtsc\n"
                          "shl $32,%%rdx\n"
                          "or %%rdx,%%rax\n"
                          "movq %%rax,%0" : "=r"(r) : : "edx", "eax", "rdx", "rax");
    return r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment