Fix overflow in KTime_GetEpochNS
This commit is contained in:
parent
c408b47966
commit
114b35bbbc
@ -194,7 +194,12 @@ KTime_GetEpochNS()
|
||||
|
||||
Spinlock_Lock(&ktimeLock);
|
||||
tscDiff = Time_GetTSC() - ktimeLastTSC;
|
||||
epoch = (ktimeLastEpoch * 1000000000) + (tscDiff * 1000000000 / ticksPerSecond);
|
||||
/*
|
||||
* This is ugly but it avoids overflowing tscDiff to time computation.
|
||||
* Note that the bottom bits of ticksPerSecond are not significant so it is
|
||||
* okay to discard them.
|
||||
*/
|
||||
epoch = (ktimeLastEpoch * 1000000000ULL) + (tscDiff * 1000000ULL / ticksPerSecond * 1000ULL);
|
||||
Spinlock_Unlock(&ktimeLock);
|
||||
|
||||
return epoch;
|
||||
|
Loading…
Reference in New Issue
Block a user