From: Tulio Magno Quites Machado Filho Date: Fri, 9 Sep 2011 05:37:11 +0000 (-0700) Subject: Optimize caa_get_cycles() for PowerPC64 X-Git-Tag: v0.6.5~30 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9a9d403acee72d36d17988ae5a6ce9ede8051f11;p=userspace-rcu.git Optimize caa_get_cycles() for PowerPC64 Make caa_get_cycles() read from the Time Base register with only 1 instruction. [ Edit by Mathieu Desnoyers: coding style update ] Signed-off-by: Mathieu Desnoyers Signed-off-by: Tulio Magno Quites Machado Filho --- diff --git a/urcu/arch/ppc.h b/urcu/arch/ppc.h index d7317bb..a03d688 100644 --- a/urcu/arch/ppc.h +++ b/urcu/arch/ppc.h @@ -48,11 +48,24 @@ extern "C" { rval; \ }) +#define mftb() \ + ({ \ + unsigned long long rval; \ + asm volatile("mftb %0" : "=r" (rval)); \ + rval; \ + }) + typedef unsigned long long cycles_t; -static inline cycles_t caa_get_cycles (void) +#ifdef __powerpc64__ +static inline cycles_t caa_get_cycles(void) { - long h, l; + return (cycles_t) mftb(); +} +#else +static inline cycles_t caa_get_cycles(void) +{ + unsigned long h, l; for (;;) { h = mftbu(); @@ -63,6 +76,7 @@ static inline cycles_t caa_get_cycles (void) return (((cycles_t) h) << 32) + l; } } +#endif #ifdef __cplusplus }