Nothing to see here, move along
1#![no_std]
2#![no_main]
3
4use lancer_user::syscall;
5
6#[unsafe(no_mangle)]
7pub extern "C" fn lancer_main() -> ! {
8 let ms = syscall::clock_monotonic_ms();
9 let secs = match ms > 0 {
10 true => ms as u64 / 1000,
11 false => 0,
12 };
13
14 let mut buf = [0u8; 22];
15 let start = fmt_u64(&mut buf, secs);
16 buf[20] = b's';
17 buf[21] = b'\n';
18 lancer_user::io::write_bytes(&buf[start..]);
19
20 syscall::exit()
21}
22
23fn fmt_u64(buf: &mut [u8; 22], n: u64) -> usize {
24 match n {
25 0 => {
26 buf[19] = b'0';
27 19
28 }
29 _ => {
30 let mut v = n;
31 (0..20).rev().fold(20usize, |pos, _| match v {
32 0 => pos,
33 _ => {
34 let np = pos - 1;
35 buf[np] = b'0' + (v % 10) as u8;
36 v /= 10;
37 np
38 }
39 })
40 }
41 }
42}