diff --git a/repos/base/src/lib/timeout/timer_connection_time.cc b/repos/base/src/lib/timeout/timer_connection_time.cc index 39e32b95d3..39ff2327e5 100644 --- a/repos/base/src/lib/timeout/timer_connection_time.cc +++ b/repos/base/src/lib/timeout/timer_connection_time.cc @@ -88,37 +88,9 @@ void Timer::Connection::_update_real_time() * Update timestamp-to-time factor and its shift */ - unsigned factor_shift = _us_to_ts_factor_shift; - uint64_t old_factor = _us_to_ts_factor; - Timestamp max_ts_diff = ~(Timestamp)0ULL >> factor_shift; - Timestamp min_ts_diff_shifted = ~(Timestamp)0ULL >> 1; - - /* - * If the calculation type is bigger than the resulting factor type, - * we have to apply further limitations to avoid a loss at the final cast. - */ - if (sizeof(Timestamp) > sizeof(uint64_t)) { - - Timestamp limit_ts_diff_shifted = (Timestamp)~0UL * us_diff; - Timestamp const limit_ts_diff = limit_ts_diff_shifted >> - factor_shift; - - /* - * Avoid that we leave the factor shift on such a high level that - * casting the factor to its final type causes a loss. - */ - if (max_ts_diff > limit_ts_diff) { - max_ts_diff = limit_ts_diff; - } - /* - * Avoid that we raise the factor shift such that casting the factor - * to its final type causes a loss. - */ - limit_ts_diff_shifted >>= 1; - if (min_ts_diff_shifted > limit_ts_diff_shifted) { - min_ts_diff_shifted = limit_ts_diff_shifted; - } - } + unsigned factor_shift = _us_to_ts_factor_shift; + uint64_t old_factor = _us_to_ts_factor; + Timestamp max_ts_diff = ~(Timestamp)0ULL >> factor_shift; struct Factor_update_failed : Genode::Exception { }; try { @@ -138,7 +110,7 @@ void Timer::Connection::_update_real_time() * Apply current shift to timestamp difference and try to even * raise the shift successively to get as much precision as possible. */ - Timestamp ts_diff_shifted = ts_diff << factor_shift; + uint64_t ts_diff_shifted = ts_diff << factor_shift; while (ts_diff_shifted < us_diff << MIN_FACTOR_LOG2) { factor_shift++; @@ -151,7 +123,7 @@ void Timer::Connection::_update_real_time() * the time difference cannot become null. */ uint64_t const new_factor = - (uint64_t)((Timestamp)ts_diff_shifted / us_diff); + (uint64_t)ts_diff_shifted / us_diff; /* update interpolation-quality value */ if (old_factor > new_factor) { _update_interpolation_quality(new_factor, old_factor); }