Skip to main content

nros_platform_time_now_ns

Function nros_platform_time_now_ns 

Source
pub unsafe extern "C" fn nros_platform_time_now_ns() -> u64
Expand description

Wall-clock nanoseconds since the Unix epoch, or 0 if the platform has no real-time clock.

ONE symbol for one fact, mirroring what RFC-0073 / phase-352 did for the monotonic clock. It replaced time_now_ms + time_since_epoch_secs + time_since_epoch_nanos (issue 0532 item 5).

Why the split had to go, beyond tidiness: the ABI spent ONE INSTANT over two symbols, and each call sampled the clock separately (the POSIX port issued its own clock_gettime in each). A second boundary landing between the two reads paired the OLD second with the NEW sub-second remainder — a timestamp that jumped a full second BACKWARDS, rarely and silently. Both nros-core and nros-node carried a bounded re-read loop to paper over it; a single read cannot tear, so those loops are gone.

u64 ns spans ~584 years from 1970, so it also retires the uint32_t seconds field, which overflowed in 2106.

Ports convert from whatever they have — a port with only seconds returns secs * 1000000000ULL, and one with no RTC returns 0. Callers wanting milliseconds divide by 1000000; wanting a (secs, nanos) pair, divide and remainder by 1000000000.