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