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 <mathieu.desnoyers@efficios.com>
Signed-off-by: Tulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
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();
return (((cycles_t) h) << 32) + l;
}
}
+#endif
#ifdef __cplusplus
}