aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/cycles.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/monniaux/cycles.h')
-rw-r--r--test/monniaux/cycles.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/monniaux/cycles.h b/test/monniaux/cycles.h
index c7dc582b..5011b18c 100644
--- a/test/monniaux/cycles.h
+++ b/test/monniaux/cycles.h
@@ -45,11 +45,16 @@ static inline cycle_t get_cycle(void) {
return cycles;
}
-#elif defined (__ARM_ARCH) && (__ARM_ARCH >= 6)
+#elif defined (__ARM_ARCH) // && (__ARM_ARCH >= 6)
#if (__ARM_ARCH < 8)
typedef uint32_t cycle_t;
#define PRcycle PRId32
+#ifdef ARM_NO_PRIVILEGE
+static inline cycle_t get_cycle(void) {
+ return 0;
+}
+#else
/* need this kernel module
https://github.com/zertyz/MTL/tree/master/cpp/time/kernel/arm */
static inline cycle_t get_cycle(void) {
@@ -57,14 +62,20 @@ static inline cycle_t get_cycle(void) {
__asm__ volatile ("mrc p15, 0, %0, c9, c13, 0":"=r" (cycles));
return cycles;
}
+#endif
#else
#define PRcycle PRId64
typedef uint64_t cycle_t;
+
+#ifdef ARM_NO_PRIVILEGE
+static inline cycle_t get_cycle(void) {
+ return 0;
+}
+#else
/* need this kernel module:
https://github.com/jerinjacobk/armv8_pmu_cycle_counter_el0
on 5+ kernels, remove first argument of access_ok macro */
-
static inline cycle_t get_cycle(void)
{
uint64_t val;
@@ -72,6 +83,7 @@ static inline cycle_t get_cycle(void)
return val;
}
#endif
+#endif
#else
#define PRcycle PRId32