rust/src/lib/time.rs

22 lines
439 B
Rust
Raw Normal View History

native "rust" mod rustrt {
2011-09-12 05:39:38 -05:00
fn get_time(&sec: u32, &usec: u32);
fn nano_time(&ns: u64);
}
2011-07-27 07:19:39 -05:00
type timeval = {sec: u32, usec: u32};
fn get_time() -> timeval {
2011-07-27 07:19:39 -05:00
let sec = 0u32;
let usec = 0u32;
2011-06-10 09:39:09 -05:00
rustrt::get_time(sec, usec);
2011-07-27 07:19:39 -05:00
ret {sec: sec, usec: usec};
}
2011-07-27 07:19:39 -05:00
fn precise_time_ns() -> u64 { let ns = 0u64; rustrt::nano_time(ns); ret ns; }
fn precise_time_s() -> float {
ret (precise_time_ns() as float) / 1000000000.;
}