]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Add support for PPC architecture, provide fallback 4507/head
authorJames Page <james.page@ubuntu.com>
Fri, 13 Mar 2015 19:46:04 +0000 (19:46 +0000)
committerLoic Dachary <ldachary@redhat.com>
Wed, 29 Apr 2015 19:16:58 +0000 (21:16 +0200)
Add high precision cpu cycles support for powerpc and powerpc64.

Provide a fallback for other architectures and warn during
compilation.

Signed-off-by: James Page <james.page@ubuntu.com>
(cherry picked from commit b2781fb5638afae7438b983a912ede126a8c5b85)

src/common/Cycles.h

index 6e47cde199e511500c0e106634669f5c58c77426..bb47d5cb029c5aa0804b28734534c17237d2bf47 100644 (file)
@@ -72,8 +72,15 @@ class Cycles {
     uint64_t cntvct;
     asm volatile ("isb; mrs %0, cntvct_el0; isb; " : "=r" (cntvct) :: "memory");
     return cntvct;
+#elif defined(__powerpc__) || defined (__powerpc64__)
+    // Based on:
+    // https://github.com/randombit/botan/blob/net.randombit.botan/src/lib/entropy/hres_timer/hres_timer.cpp
+    uint32_t lo = 0, hi = 0;
+    asm volatile("mftbu %0; mftb %1" : "=r" (hi), "=r" (lo));
+    return (((uint64_t)hi << 32) | lo);
 #else
-#error No high-precision counter available for your OS/arch
+#warning No high-precision counter available for your OS/arch
+    return 0;
 #endif
   }