Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / tools / perf / util / tsc.c
blob1b741646eed00b7754ba0a618b4fb57b8c87d9ac
1 #include <linux/compiler.h>
2 #include <linux/types.h>
4 #include "tsc.h"
6 u64 perf_time_to_tsc(u64 ns, struct perf_tsc_conversion *tc)
8 u64 t, quot, rem;
10 t = ns - tc->time_zero;
11 quot = t / tc->time_mult;
12 rem = t % tc->time_mult;
13 return (quot << tc->time_shift) +
14 (rem << tc->time_shift) / tc->time_mult;
17 u64 tsc_to_perf_time(u64 cyc, struct perf_tsc_conversion *tc)
19 u64 quot, rem;
21 quot = cyc >> tc->time_shift;
22 rem = cyc & (((u64)1 << tc->time_shift) - 1);
23 return tc->time_zero + quot * tc->time_mult +
24 ((rem * tc->time_mult) >> tc->time_shift);
27 u64 __weak rdtsc(void)
29 return 0;