[PATCH 2/2] CodeSamples: Switch ARM64 get_timestamp() to use the hardware counter

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Elad Lahav <e2lahav@xxxxxxxxx>
---
 CodeSamples/arch-arm64/arch-arm64.h | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/CodeSamples/arch-arm64/arch-arm64.h b/CodeSamples/arch-arm64/arch-arm64.h
index f45d8bdc..220b8b16 100644
--- a/CodeSamples/arch-arm64/arch-arm64.h
+++ b/CodeSamples/arch-arm64/arch-arm64.h
@@ -43,24 +43,13 @@
 #define smp_mb()  __asm__ __volatile__("dmb ish" : : : "memory")
 
 
-#include <stdlib.h>
-#include <time.h>
-
-#ifndef CLOCK_MONOTONIC_RAW
-#define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
-#endif
-
 /*
  * Generate 64-bit timestamp.
  */
-static __inline__ unsigned long long get_timestamp(void)
+static inline unsigned long long get_timestamp(void)
 {
 	unsigned long long thetime;
-	struct timespec tv;
 
-	if (clock_gettime(CLOCK_MONOTONIC_RAW, &tv) != 0)
-		return 0;
-	thetime = ((unsigned long long)tv.tv_sec) * 1000000000ULL +
-		  ((unsigned long long)tv.tv_nsec);
+	__asm__ __volatile__ ("isb; mrs %0, cntvct_el0" : "=r"(thetime));
 	return thetime;
 }
-- 
2.25.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux