The routine could loop infinitely when rounding a large value, replace
it with our_lround.
/* ================================================== */
-inline static int
-our_round(double x) {
- int y;
- y = (int)(x + 0.5);
- while ((double)y < x - 0.5) y++;
- while ((double)y > x + 0.5) y--;
- return y;
-}
-
inline static long
-our_lround(double x) {
- int y;
+our_round(double x) {
+ long y;
if (x > 0.0)
y = x + 0.5;
if (fabs(offset_register) < MAX_ADJUST_WITH_ADJTIME) {
/* Use adjtime to do the shift */
- offset = our_lround(1.0e6 * -offset_register);
+ offset = our_round(1.0e6 * -offset_register);
offset_register += offset * 1e-6;