aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/cycles.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/include/asm/cycles.h')
-rw-r--r--arch/x86/include/asm/cycles.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/arch/x86/include/asm/cycles.h b/arch/x86/include/asm/cycles.h
new file mode 100644
index 0000000..00a7593
--- /dev/null
+++ b/arch/x86/include/asm/cycles.h
@@ -0,0 +1,30 @@
1#ifndef ASM_CYCLES_H
2#define ASM_CYCLES_H
3
4#define rdtscll(val) do { \
5 unsigned int __a,__d; \
6 __asm__ __volatile__("rdtsc" : "=a" (__a), "=d" (__d)); \
7 (val) = ((unsigned long long)__a) | (((unsigned long long)__d)<<32); \
8} while(0)
9
10static __inline__ unsigned long long native_read_tsc(void)
11{
12 unsigned long long val;
13
14 __asm__ __volatile__("mfence":::"memory");
15 rdtscll(val);
16 __asm__ __volatile__("mfence":::"memory");
17
18 return val;
19}
20
21#define CYCLES_FMT "llu"
22
23typedef unsigned long long cycles_t;
24
25static inline cycles_t get_cycles(void)
26{
27 return native_read_tsc();
28}
29
30#endif