Optimize caa_get_cycles() for PowerPC64
authorTulio Magno Quites Machado Filho <tuliom@linux.vnet.ibm.com>
Fri, 9 Sep 2011 05:37:11 +0000 (22:37 -0700)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 9 Sep 2011 05:37:11 +0000 (22:37 -0700)
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>
urcu/arch/ppc.h

index d7317bb327c72afa48f087f50251cbe311a2ff62..a03d688837344f0bb2d438c7161d43dcb208a5ef 100644 (file)
@@ -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 
 }
This page took 0.025919 seconds and 4 git commands to generate.