File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change 11use core:: hint:: spin_loop;
2- use core:: num:: NonZeroU64 ;
32
43use hermit_entry:: boot_info:: PlatformInfo ;
5- use hermit_sync:: without_interrupts;
4+ use hermit_sync:: { without_interrupts, OnceCell } ;
65use time:: OffsetDateTime ;
76use 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
176175pub fn get_boot_time ( ) -> u64 {
177- unsafe { BOOT_TIME . unwrap ( ) . get ( ) }
176+ * BOOT_TIME . get ( ) . unwrap ( )
178177}
179178
180179pub 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}
You can’t perform that action at this time.
0 commit comments