Optimize caa_get_cycles() for PowerPC64
[urcu.git] / 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.023086 seconds and 4 git commands to generate.