2011-10-27 16:54:18 -05:00
|
|
|
/*
|
|
|
|
Module: time
|
|
|
|
*/
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-10-27 16:54:18 -05:00
|
|
|
// FIXME: Document what these functions do
|
2011-06-15 13:19:50 -05:00
|
|
|
|
2011-11-16 22:49:38 -06:00
|
|
|
#[abi = "cdecl"]
|
|
|
|
native mod rustrt {
|
2011-09-12 05:39:38 -05:00
|
|
|
fn get_time(&sec: u32, &usec: u32);
|
|
|
|
fn nano_time(&ns: u64);
|
2011-04-29 13:54:06 -05:00
|
|
|
}
|
|
|
|
|
2011-10-27 16:54:18 -05:00
|
|
|
/* Type: timeval */
|
2011-07-27 07:19:39 -05:00
|
|
|
type timeval = {sec: u32, usec: u32};
|
2011-04-29 13:54:06 -05:00
|
|
|
|
2011-10-27 16:54:18 -05:00
|
|
|
/* Function: get_time */
|
2011-04-29 13:54:06 -05:00
|
|
|
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-06-28 19:58:44 -05:00
|
|
|
}
|
|
|
|
|
2011-10-27 16:54:18 -05:00
|
|
|
/* Function: precise_time_ns */
|
2011-07-27 07:19:39 -05:00
|
|
|
fn precise_time_ns() -> u64 { let ns = 0u64; rustrt::nano_time(ns); ret ns; }
|
2011-06-28 19:58:44 -05:00
|
|
|
|
2011-10-27 16:54:18 -05:00
|
|
|
/* Function: precise_time_s */
|
2011-06-28 19:58:44 -05:00
|
|
|
fn precise_time_s() -> float {
|
|
|
|
ret (precise_time_ns() as float) / 1000000000.;
|
2011-08-19 17:16:48 -05:00
|
|
|
}
|