aboutsummaryrefslogtreecommitdiff
path: root/ctr-std
diff options
context:
space:
mode:
authorFenrir <[email protected]>2017-02-04 13:10:53 -0700
committerFenrir <[email protected]>2017-02-18 18:04:15 -0700
commit1f35866047432edd316df3181261cb883032d844 (patch)
tree5b71db0d3f567d6a64e7c03e48301d6f161d5071 /ctr-std
parentuse libc types in Instant impl (diff)
downloadctru-rs-1f35866047432edd316df3181261cb883032d844.tar.xz
ctru-rs-1f35866047432edd316df3181261cb883032d844.zip
Yet another bugfix
Also renamed stuff and improved the documentation
Diffstat (limited to 'ctr-std')
-rw-r--r--ctr-std/src/sys/unix/time.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/ctr-std/src/sys/unix/time.rs b/ctr-std/src/sys/unix/time.rs
index e6409ce..f4e24e4 100644
--- a/ctr-std/src/sys/unix/time.rs
+++ b/ctr-std/src/sys/unix/time.rs
@@ -135,11 +135,11 @@ mod inner {
impl Instant {
pub fn now() -> Instant {
- let ms = monotonic_ms();
+ let usec = monotonic_usec();
let s = libc::timeval {
- tv_sec: (ms / 1_000_000) as libc::time_t,
- tv_usec: (ms % 1_000_000) as libc::c_long,
+ tv_sec: (usec / 1_000_000) as libc::time_t,
+ tv_usec: (usec % 1_000_000) as libc::c_long,
};
return Instant::from(s)
}
@@ -162,16 +162,17 @@ mod inner {
// The initial system tick after which all Instants occur
static TICK: spin::Once<u64> = spin::Once::new();
- // Returns a monotonic timer in microseconds
+ // A source of monotonic time based on ticks of the 3DS CPU. Returns the
+ // number of microseconds elapsed since an arbitrary time in the past
//
// Note that svcGetSystemTick always runs at 268MHz, even on a
// New 3DS running in 804MHz mode
//
// See https://www.3dbrew.org/wiki/Hardware#Common_hardware
- fn monotonic_ms() -> u64 {
+ fn monotonic_usec() -> u64 {
let first_tick = get_first_tick();
let current_tick = get_system_tick();
- (current_tick - first_tick / 268)
+ (current_tick - first_tick) / 268
}
// The first time this function is called, it generates and returns the