Use u128 on Clock Cycles calculation.
This commit is contained in:
parent
68927866e2
commit
435c39e867
5 changed files with 32 additions and 27 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <cinttypes>
|
||||
#include <limits>
|
||||
#include "common/logging/log.h"
|
||||
#include "common/uint128.h"
|
||||
|
||||
namespace Core::Timing {
|
||||
|
||||
|
@ -61,10 +62,9 @@ s64 nsToCycles(u64 ns) {
|
|||
}
|
||||
|
||||
u64 CpuCyclesToClockCycles(u64 ticks) {
|
||||
u64 result = ticks;
|
||||
result *= CNTFREQ;
|
||||
result /= BASE_CLOCK_RATE;
|
||||
return static_cast<u64>(result);
|
||||
u128 temporal = Common::Multiply64Into128(ticks, CNTFREQ);
|
||||
std::pair<u64, u64> result = Common::Divide128On64(temporal, BASE_CLOCK_RATE);
|
||||
return result.first;
|
||||
}
|
||||
|
||||
} // namespace Core::Timing
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue