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 1
1
use core:: hint:: spin_loop;
2
- use core:: num:: NonZeroU64 ;
3
2
4
3
use hermit_entry:: boot_info:: PlatformInfo ;
5
- use hermit_sync:: without_interrupts;
4
+ use hermit_sync:: { without_interrupts, OnceCell } ;
6
5
use time:: OffsetDateTime ;
7
6
use x86:: io:: * ;
8
7
@@ -171,10 +170,10 @@ impl Rtc {
171
170
}
172
171
}
173
172
174
- static mut BOOT_TIME : Option < NonZeroU64 > = None ;
173
+ static BOOT_TIME : OnceCell < u64 > = OnceCell :: new ( ) ;
175
174
176
175
pub fn get_boot_time ( ) -> u64 {
177
- unsafe { BOOT_TIME . unwrap ( ) . get ( ) }
176
+ * BOOT_TIME . get ( ) . unwrap ( )
178
177
}
179
178
180
179
pub fn init ( ) {
@@ -191,7 +190,5 @@ pub fn init() {
191
190
info ! ( "HermitCore-rs booted on {boot_time}" ) ;
192
191
193
192
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 ( ) ;
197
194
}
You can’t perform that action at this time.
0 commit comments