arm: Rename armTickToNs(), etc

This commit is contained in:
plutooo 2018-10-28 17:37:56 +01:00
parent ddc49e5178
commit cdd3eb74a0
3 changed files with 16 additions and 6 deletions

View File

@ -27,10 +27,20 @@ static inline u64 armGetSystemTickFreq(void) {
return ret;
}
static inline u64 armNsToTick(u64 ns) {
/**
* @brief Converts from nanoseconds to CPU ticks unit.
* @param ns Time in nanoseconds.
* @return Time in CPU ticks.
*/
static inline u64 armNsToTicks(u64 ns) {
return (ns * 12) / 625;
}
static inline u64 armTickToNs(u64 tick) {
/**
* @brief Converts from CPU ticks unit to nanoseconds.
* @param tick Time in ticks.
* @return Time in nanoseconds.
*/
static inline u64 armTicksToNs(u64 tick) {
return (tick * 625) / 12;
}

View File

@ -36,14 +36,14 @@ Result eventWait(Event* t, u64 timeout)
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
if (timeout != U64_MAX)
deadline = armGetSystemTick() + armNsToTick(timeout); // timeout: ns->ticks
deadline = armGetSystemTick() + armNsToTicks(timeout); // timeout: ns->ticks
do {
do {
s64 this_timeout = -1;
if (deadline) {
this_timeout = deadline - armGetSystemTick();
this_timeout = armTickToNs(this_timeout >= 0 ? this_timeout : 0); // ticks->ns
this_timeout = armTicksToNs(this_timeout >= 0 ? this_timeout : 0); // ticks->ns
}
rc = svcWaitSynchronizationSingle(t->revent, this_timeout);

View File

@ -6,7 +6,7 @@
void utimerCreate(UsermodeTimer* t, u64 interval, bool start)
{
t->next_time = 0;
t->interval = armNsToTick(interval);
t->interval = armNsToTicks(interval);
if (start)
utimerStart(t);
@ -15,7 +15,7 @@ void utimerCreate(UsermodeTimer* t, u64 interval, bool start)
void utimerStart(UsermodeTimer* t)
{
u64 zero = 0;
__atomic_compare_exchange_n(&t->next_time, &zero, armGetSystemTick() + armNsToTick(t->interval), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
__atomic_compare_exchange_n(&t->next_time, &zero, armGetSystemTick() + armNsToTicks(t->interval), false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
}
void utimerStop(UsermodeTimer* t)