Replace casting of values incremented by +0.5/-0.5 with round().
int poll;
destination = ARR_GetElement(broadcasts, (long)arg);
- poll = log(destination->interval) / log(2.0) + 0.5;
+ poll = round(log(destination->interval) / log(2.0));
UTI_ZeroNtp64(&orig_ts);
zero_local_timestamp(&recv_ts);
}
/* Align the offset to the reference sample */
- if ((ref_sample.offset - offset) >= 0.0)
- shift = (long)((ref_sample.offset - offset) * rate + 0.5) / (double)rate;
- else
- shift = (long)((ref_sample.offset - offset) * rate - 0.5) / (double)rate;
+ shift = round((ref_sample.offset - offset) * rate) / rate;
offset += shift;
updated in the kernel */
static int tick_update_hz;
-/* ================================================== */
-
-inline static long
-our_round(double x)
-{
- long y;
-
- if (x > 0.0)
- y = x + 0.5;
- else
- y = x - 0.5;
-
- return y;
-}
-
/* ================================================== */
/* Positive means currently fast of true time, i.e. jump backwards */
double required_freq;
int required_delta_tick;
- required_delta_tick = our_round(freq_ppm / dhz);
+ required_delta_tick = round(freq_ppm / dhz);
/* Older kernels (pre-2.6.18) don't apply the frequency offset exactly as
set by adjtimex() and a scaling constant (that depends on the internal
b->tv_sec = a;
frac_part = 1.0e6 * (a - b->tv_sec);
- b->tv_usec = frac_part > 0 ? frac_part + 0.5 : frac_part - 0.5;
+ b->tv_usec = round(frac_part);
UTI_NormaliseTimeval(b);
}