sparkles-core 0.1.8

Core crate for sparkles
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use core::arch::asm;
use crate::timestamp::TimestampProvider;

pub struct AArch64Timestamp;

impl TimestampProvider for AArch64Timestamp {
    type TimestampType = u64;

    #[inline(always)]
    fn now() -> Self::TimestampType {
        let value: u64;
        unsafe {
            asm!("mrs {}, cntvct_el0", out(reg) value); // Read the virtual counter
        }
        value
    }
}