Skip to content

Commit 0e5e1aa

Browse files
authored
Merge pull request ceph#65120 from leiwen2025/wip-add-rv64-high-precision-counter-support
common/Cycles: Add high-precision counter support for riscv64 Reviewed-by: Kefu Chai <[email protected]>
2 parents 6d8e9e4 + f8fc29d commit 0e5e1aa

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/common/Cycles.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class Cycles {
8484
uint64_t tsc;
8585
asm volatile("stck %0" : "=Q" (tsc) : : "cc");
8686
return tsc;
87+
#elif defined(__riscv) && __riscv_xlen == 64
88+
uint64_t tsc;
89+
asm volatile ("rdtime %0" : "=r" (tsc));
90+
return tsc;
8791
#else
8892
#warning No high-precision counter available for your OS/arch
8993
return 0;

0 commit comments

Comments
 (0)