Lines 2094-2113
Link Here
|
2094 |
* years) and in 64 bits at 4 GHz (146 years), but if we do a multiply |
2094 |
* years) and in 64 bits at 4 GHz (146 years), but if we do a multiply |
2095 |
* before divide conversion (to retain precision) we find that the |
2095 |
* before divide conversion (to retain precision) we find that the |
2096 |
* margin shrinks to 1.5 hours (one millionth of 146y). |
2096 |
* margin shrinks to 1.5 hours (one millionth of 146y). |
2097 |
* With a three prong approach we never lose significant bits, no |
|
|
2098 |
* matter what the cputick rate and length of timeinterval is. |
2099 |
*/ |
2097 |
*/ |
2100 |
|
2098 |
|
2101 |
uint64_t |
2099 |
uint64_t |
2102 |
cputick2usec(uint64_t tick) |
2100 |
cputick2usec(uint64_t tick) |
2103 |
{ |
2101 |
{ |
2104 |
|
2102 |
uint64_t tr; |
2105 |
if (tick > 18446744073709551LL) /* floor(2^64 / 1000) */ |
2103 |
tr = cpu_tickrate(); |
2106 |
return (tick / (cpu_tickrate() / 1000000LL)); |
2104 |
return ((tick / tr) * 1000000ULL) + ((tick % tr) * 1000000ULL) / tr; |
2107 |
else if (tick > 18446744073709LL) /* floor(2^64 / 1000000) */ |
|
|
2108 |
return ((tick * 1000LL) / (cpu_tickrate() / 1000LL)); |
2109 |
else |
2110 |
return ((tick * 1000000LL) / cpu_tickrate()); |
2111 |
} |
2105 |
} |
2112 |
|
2106 |
|
2113 |
cpu_tick_f *cpu_ticks = tc_cpu_ticks; |
2107 |
cpu_tick_f *cpu_ticks = tc_cpu_ticks; |