#![no_std] #![no_main] use lancer_user::syscall; #[unsafe(no_mangle)] pub extern "C" fn lancer_main() -> ! { let ms = syscall::clock_monotonic_ms(); let secs = match ms > 0 { true => ms as u64 / 1000, false => 0, }; let mut buf = [0u8; 22]; let start = fmt_u64(&mut buf, secs); buf[20] = b's'; buf[21] = b'\n'; lancer_user::io::write_bytes(&buf[start..]); syscall::exit() } fn fmt_u64(buf: &mut [u8; 22], n: u64) -> usize { match n { 0 => { buf[19] = b'0'; 19 } _ => { let mut v = n; (0..20).rev().fold(20usize, |pos, _| match v { 0 => pos, _ => { let np = pos - 1; buf[np] = b'0' + (v % 10) as u8; v /= 10; np } }) } } }