()
| 5 | #[cfg(target_arch = "aarch64")] |
| 6 | #[inline(always)] |
| 7 | pub fn ticks() -> u64 { |
| 8 | use core::arch::asm; |
| 9 | let cnt: u64; |
| 10 | // SAFETY: `mrs cntvct_el0` only reads the architectural virtual counter |
| 11 | // register: it touches neither memory (`nomem`) nor the stack (`nostack`), |
| 12 | // and writes no condition flags (`preserves_flags`). |
| 13 | unsafe { |
| 14 | asm!( |
| 15 | "mrs {}, cntvct_el0", |
| 16 | out(reg) cnt, |
| 17 | options(nostack, nomem, preserves_flags) |
| 18 | ); |
| 19 | } |
| 20 | cnt |
| 21 | } |
| 22 | |
| 23 | /// Read from rdtime on RISC-V |