code wiki / (root) / time.nx

time.nx

buildroot/runtime/time.nx

2492 B76 linesdepth 0pulls 0 transitivereach 1 importersview sourcekind tooltopic time
docsdependenciesstructsconstsfunctions

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

time.nx nxrun.nx

imports: none

imported by: nxrun.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main monotonic_ns sys_clock_gettime wall_clock_ns sys_clock_gettime ↻

structs

23struct TimeSpec {

consts

20const CLOCK_REALTIME: i64 = 0
21const CLOCK_MONOTONIC: i64 = 1

functions

28func sys_clock_gettime(clk_id: i64, ts: *TimeSpec) -> i64 {
36func monotonic_ns() -> i64 {
called by 2: time_execmain calls 1: sys_clock_gettime
47func wall_clock_ns() -> i64 {
called by 1: main calls 1: sys_clock_gettime
64func main() -> i64 {