aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/cycles.h
blob: 00a75935de412d7b414e74f038704b38516c12e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef ASM_CYCLES_H
#define ASM_CYCLES_H

#define rdtscll(val) do { \
	unsigned int __a,__d; \
	__asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); \
	(val) = ((unsigned long long)__a) | (((unsigned long long)__d)<<32); \
} while(0)

static __inline__ unsigned long long native_read_tsc(void)
{
	unsigned long long val;

	__asm__ __volatile__("mfence":::"memory");
	rdtscll(val);
	__asm__ __volatile__("mfence":::"memory");

	return val;
}

#define CYCLES_FMT "llu"

typedef unsigned long long cycles_t;

static inline cycles_t get_cycles(void)
{
	return native_read_tsc();
}

#endif