time.nx
buildroot/runtime/time.nx
about
time.nx -- monotonic + wall clock, via Linux/NishiOS clock_gettime.
Zero third-party runtime: only __syscall. Syscall 113 is
clock_gettime(clk_id, *timespec); returns 0 on success, -1 on error.
Linux RV64 numbers; NishiOS keeps the same set.
TimeSpec layout matches Linux's `struct timespec`: two i64 fields,
seconds + nanoseconds. `var ts: TimeSpec` stack-allocates via the
compiler's alloca path; `&ts` hands the kernel a pointer to write
into.
Callers generally want ns since some origin:
* monotonic_ns() -- ns since boot; cannot go backwards; immune to
wall-clock jumps (NTP, DST, manual set). Use for timing.
* wall_clock_ns() -- ns since Unix epoch; CAN jump. Use only for
human-readable timestamps and inter-machine correlation.
dependencies 0 imports · 1 importers
imports: none
imported by: nxrun.nx
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| 23 | struct TimeSpec { |
consts
| 20 | const CLOCK_REALTIME: i64 = 0 |
| 21 | const CLOCK_MONOTONIC: i64 = 1 |
functions
| 28 | func sys_clock_gettime(clk_id: i64, ts: *TimeSpec) -> i64 { |
| 36 | func monotonic_ns() -> i64 { |
| 47 | func wall_clock_ns() -> i64 { |
| 64 | func main() -> i64 { |