Skip to content

Commit

Permalink
Add code for getting timestamp from mrs (async-profiler#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
arielb1 authored Feb 18, 2025
1 parent 2d764cc commit f71c31a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/tsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@ static bool cpuHasGoodTimestampCounter() {
return (edx & (1 << 8)) != 0;
}

#elif defined(__aarch64__)

#define TSC_SUPPORTED true

static inline u64 rdtsc() {
u64 value;
asm volatile("mrs %0, cntvct_el0" : "=r"(value));
return value;
}

static bool cpuHasGoodTimestampCounter() {
// AARCH64 always has a good timestamp counter.
return true;
}

#else

#define TSC_SUPPORTED false
Expand Down

0 comments on commit f71c31a

Please # to comment.