#define rdtscll(val) __asm__ __volatile__ ("rdtsc" : "=A" (val))
example
#include<stdio.h> int i; unsigned long e; #define as(p) __asm__ __volatile__ (p) #define rdtscll() as("rdtsc") int main(void) { rdtscll(); as("movl %eax,%ecx"); rdtscll(); as("subl %ecx,%eax"); as("movl %eax,e"); printf("duration:%lld ", e); return 0; }