diff options
author | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-06 16:36:31 -0400 |
---|---|---|
committer | Bjoern B. Brandenburg <bbb@cs.unc.edu> | 2010-11-09 16:35:32 -0500 |
commit | f8585fe1fc6f0830f900dad7c8ccc40e17f79644 (patch) | |
tree | a89c87d7f2b2002e4ac77ca34b63209ed98d66a1 /arch | |
parent | 42e747e4fe5648967c1ead5ae327b5fbbe66f2e5 (diff) |
refactor: use architecture-specific includes for cycles.h
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/include/asm/cycles.h | 16 | ||||
-rw-r--r-- | arch/x86/include/asm/cycles.h | 30 |
2 files changed, 46 insertions, 0 deletions
diff --git a/arch/sparc64/include/asm/cycles.h b/arch/sparc64/include/asm/cycles.h new file mode 100644 index 0000000..ce0e8ce --- /dev/null +++ b/arch/sparc64/include/asm/cycles.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef ASM_CYCLES_H | ||
2 | #define ASM_CYCLES_H | ||
3 | |||
4 | #define NPT_BIT 63 | ||
5 | |||
6 | typedef unsigned long cycles_t; | ||
7 | |||
8 | #define CYCLES_FMT "lu" | ||
9 | |||
10 | static inline cycles_t get_cycles(void) { | ||
11 | cycles_t cycles = 0; | ||
12 | __asm__ __volatile__("rd %%asr24, %0" : "=r" (cycles)); | ||
13 | return cycles & ~(1UL << NPT_BIT); | ||
14 | } | ||
15 | |||
16 | #endif | ||
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 | |||
10 | static __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 | |||
23 | typedef unsigned long long cycles_t; | ||
24 | |||
25 | static inline cycles_t get_cycles(void) | ||
26 | { | ||
27 | return native_read_tsc(); | ||
28 | } | ||
29 | |||
30 | #endif | ||