]> git.sesse.net Git - x264/commitdiff
checkasm: add cycle counter read for aarch64
authorJanne Grunau <janne-x264@jannau.net>
Thu, 6 Nov 2014 08:20:17 +0000 (09:20 +0100)
committerAnton Mitrofanov <BugMaster@narod.ru>
Tue, 16 Dec 2014 17:40:11 +0000 (20:40 +0300)
Needs kernel support since user space access to the cycle counter is not
allowed on all available AArch64 systems (Android 5 and iOS).

tools/checkasm.c

index a348aa18c8df89f8ad76f5348b1f891f684864c5..c90c0cfcd56640fdc9217b3740435c790c368053 100644 (file)
@@ -97,6 +97,10 @@ static inline uint32_t read_time(void)
     asm volatile( "mftb %0" : "=r"(a) :: "memory" );
 #elif ARCH_ARM     // ARMv7 only
     asm volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(a) :: "memory" );
+#elif ARCH_AARCH64
+    uint64_t b = 0;
+    asm volatile( "mrs %0, pmccntr_el0" : "=r"(b) :: "memory" );
+    a = b;
 #endif
     return a;
 }
@@ -2764,7 +2768,7 @@ int main(int argc, char *argv[])
 
     if( argc > 1 && !strncmp( argv[1], "--bench", 7 ) )
     {
-#if !ARCH_X86 && !ARCH_X86_64 && !ARCH_PPC && !ARCH_ARM
+#if !ARCH_X86 && !ARCH_X86_64 && !ARCH_PPC && !ARCH_ARM && !ARCH_AARCH64
         fprintf( stderr, "no --bench for your cpu until you port rdtsc\n" );
         return 1;
 #endif