5.1.2 : The source (timer.cpp)

The timer.cpp is :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include "timer.h"

#ifdef __i386
extern long unsigned int rdtsc(void) {
	long unsigned int x;
	__asm__ volatile ("rdtsc" : "=A" (x));
	return x;
}
#elif defined __amd64
extern long unsigned int rdtsc(void) {
	long unsigned int a, d;
	__asm__ volatile ("rdtsc" : "=a" (a), "=d" (d));
	return (d<<32) | a;
}
#endif