// time — clocks. We expose monotonic-ns via a syscall trampoline. // Linux clock_gettime is syscall 228; clock id 1 is CLOCK_MONOTONIC. // Until we can pass struct-by-value the user supplies a buffer. @symbol("rt_syscall") fn syscall(num: i64, a: i64, b: i64, c: i64) i64; def CLOCK_MONOTONIC: i64 = 1; def SYS_CLOCK_GETTIME: i64 = 228; // timespec is {sec, nsec} — 16 bytes. Caller passes a pointer. type timespec = struct { sec: i64, nsec: i64 }; export fn monotonic(ts: *timespec) i32 = { return syscall(SYS_CLOCK_GETTIME, CLOCK_MONOTONIC, ts: i64, 0): i32; };