X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=time.c;h=155e11d86e99dcbdef2535108c5602fa1752efc5;hp=b77138295c2ded13d8890cf3e626a7a8a0df3494;hb=eb578d92fd87aeb86c0832689000dc772e689f92;hpb=755bbd9fa36e16f266467bed60b158e5737bd838 diff --git a/time.c b/time.c index b7713829..155e11d8 100644 --- a/time.c +++ b/time.c @@ -121,17 +121,10 @@ void tv_scale(const unsigned long mult, const struct timeval *tv, void tv_divide(const unsigned long divisor, const struct timeval *tv, struct timeval *result) { - long unsigned q; + uint64_t x = ((uint64_t)tv->tv_sec * 1000 * 1000 + tv->tv_usec) / divisor; - q = tv->tv_usec / divisor; - result->tv_sec = tv->tv_sec / divisor; - result->tv_usec = (tv->tv_sec - result->tv_sec * divisor) - * 1000 * 1000 / divisor; - if (result->tv_usec + q >= 1000 * 1000) { - result->tv_sec++; - result->tv_usec = 1000 * 1000 - result->tv_usec - q; - } else - result->tv_usec += q; + result->tv_sec = x / 1000 / 1000; + result->tv_usec = x % (1000 * 1000); } /**