You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Looking at the implementation of osGetTime (which is used by gettimeofday, which in turn is used by our clock_gettime impl for CLOCK_REALTIME), they appear to do some adjustment for clock drift in an attempt to get monotonic values, but I'm not sure if that implies the value from svcGetSystemTick() is not normally monotonic? There is also an epoch adjustment from 1900 to 1970 here for gettimeofday, but I don't think that would be strictly needed for a monotonic clock_gettime...
So maybe we could try our own impl that basically looks like this?
let now = svcGetSystemTick();// Not sure if the math is quite right but you get the idea...(*tp).tv_sec = now / SYSCLOCK_ARM11;(*tp).tv_nsec = 1000*(now - SYSCLOCK_ARM11*(*tp).tv_sec) / CPU_TICKS_PER_USEC;
I have to imagine that svcGetSystemTick() is monotonic, since I think it's supposed to be the number of clock cycles since boot, based on this docstring
I can work on this soon but wanted to track it here, also wanted to wait for the discussion in #8 to be finalized so we can come up with a best practice for exposing libctru APIs through libc like this, since the error handling will probably be similar.
The text was updated successfully, but these errors were encountered:
From discussion starting at Meziu/rust-horizon#6 (comment)
Looking at the implementation of
osGetTime
(which is used bygettimeofday
, which in turn is used by ourclock_gettime
impl forCLOCK_REALTIME
), they appear to do some adjustment for clock drift in an attempt to get monotonic values, but I'm not sure if that implies the value fromsvcGetSystemTick()
is not normally monotonic? There is also an epoch adjustment from 1900 to 1970 here forgettimeofday
, but I don't think that would be strictly needed for a monotonicclock_gettime
...So maybe we could try our own impl that basically looks like this?
I have to imagine that
svcGetSystemTick()
is monotonic, since I think it's supposed to be the number of clock cycles since boot, based on this docstringOriginally posted by @ian-h-chamberlain in Meziu/rust-horizon#6 (comment)
I can work on this soon but wanted to track it here, also wanted to wait for the discussion in #8 to be finalized so we can come up with a best practice for exposing
libctru
APIs through libc like this, since the error handling will probably be similar.The text was updated successfully, but these errors were encountered: