1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use core::sync::atomic::{AtomicU32, Ordering};
use crate::sched;
pub(crate) struct Duration {
ticks: u64
}
#[allow(dead_code)]
impl Duration {
pub const fn from_millis(millis: u64) -> Self {
Duration {
ticks: millis,
}
}
pub const fn infinite() -> Self {
Duration {
ticks: u64::MAX,
}
}
pub fn ticks(&self) -> u64 {
self.ticks
}
}
static COUNT: AtomicU32 = AtomicU32::new(0);
#[no_mangle]
#[inline(always)]
fn system_tick_update() {
COUNT.fetch_add(1, Ordering::Relaxed);
sched::tick_update();
}
pub fn tick() -> u64 {
COUNT.load(Ordering::Relaxed) as u64
}