Browse Source

Yet another bugfix

Also renamed stuff and improved the documentation
pull/10/head
Fenrir 8 years ago
parent
commit
1f35866047
  1. 13
      ctr-std/src/sys/unix/time.rs

13
ctr-std/src/sys/unix/time.rs

@ -135,11 +135,11 @@ mod inner {
impl Instant { impl Instant {
pub fn now() -> Instant { pub fn now() -> Instant {
let ms = monotonic_ms(); let usec = monotonic_usec();
let s = libc::timeval { let s = libc::timeval {
tv_sec: (ms / 1_000_000) as libc::time_t, tv_sec: (usec / 1_000_000) as libc::time_t,
tv_usec: (ms % 1_000_000) as libc::c_long, tv_usec: (usec % 1_000_000) as libc::c_long,
}; };
return Instant::from(s) return Instant::from(s)
} }
@ -162,16 +162,17 @@ mod inner {
// The initial system tick after which all Instants occur // The initial system tick after which all Instants occur
static TICK: spin::Once<u64> = spin::Once::new(); 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 // Note that svcGetSystemTick always runs at 268MHz, even on a
// New 3DS running in 804MHz mode // New 3DS running in 804MHz mode
// //
// See https://www.3dbrew.org/wiki/Hardware#Common_hardware // See https://www.3dbrew.org/wiki/Hardware#Common_hardware
fn monotonic_ms() -> u64 { fn monotonic_usec() -> u64 {
let first_tick = get_first_tick(); let first_tick = get_first_tick();
let current_tick = get_system_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 // The first time this function is called, it generates and returns the

Loading…
Cancel
Save