[−][src]Function solana_rbpf::syscalls::bpf_time_getns
pub fn bpf_time_getns<E: UserDefinedError>(
_arg1: u64,
_arg2: u64,
_arg3: u64,
_arg4: u64,
_arg5: u64,
_ro_regions: &[MemoryRegion],
_rw_regions: &[MemoryRegion]
) -> Result<u64, EbpfError<E>>
Get monotonic time (since boot time) in nanoseconds. All arguments are unused.
Examples
use solana_rbpf::syscalls::bpf_time_getns; use solana_rbpf::memory_region::MemoryRegion; use solana_rbpf::user_error::UserError; let regions = [MemoryRegion::default()]; let t = bpf_time_getns::<UserError>(0, 0, 0, 0, 0, ®ions, ®ions).unwrap(); let d = t / 10u64.pow(9) / 60 / 60 / 24; let h = (t / 10u64.pow(9) / 60 / 60) % 24; let m = (t / 10u64.pow(9) / 60 ) % 60; let s = (t / 10u64.pow(9)) % 60; let ns = t % 10u64.pow(9); println!("Uptime: {:#x} == {} days {}:{}:{}, {} ns", t, d, h, m, s, ns);