Skip to content

Commit 10e5589

Browse files
committed
Systemtime: Remove static mut
1 parent b44a32b commit 10e5589

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/arch/x86_64/kernel/systemtime.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use core::hint::spin_loop;
2-
use core::num::NonZeroU64;
32

43
use hermit_entry::boot_info::PlatformInfo;
5-
use hermit_sync::without_interrupts;
4+
use hermit_sync::{without_interrupts, OnceCell};
65
use time::OffsetDateTime;
76
use x86::io::*;
87

@@ -171,10 +170,10 @@ impl Rtc {
171170
}
172171
}
173172

174-
static mut BOOT_TIME: Option<NonZeroU64> = None;
173+
static BOOT_TIME: OnceCell<u64> = OnceCell::new();
175174

176175
pub fn get_boot_time() -> u64 {
177-
unsafe { BOOT_TIME.unwrap().get() }
176+
*BOOT_TIME.get().unwrap()
178177
}
179178

180179
pub fn init() {
@@ -191,7 +190,5 @@ pub fn init() {
191190
info!("HermitCore-rs booted on {boot_time}");
192191

193192
let micros = u64::try_from(boot_time.unix_timestamp_nanos() / 1000).unwrap();
194-
unsafe {
195-
BOOT_TIME = Some(micros.try_into().unwrap());
196-
}
193+
BOOT_TIME.set(micros).unwrap();
197194
}

0 commit comments

Comments
 (0)