X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=time.c;h=0cb9babe2ae8de65be0fdfdc4e65ee6a626688e8;hp=6e1d603d2751566f3afa55d518367e162ae1b06b;hb=3f9051d22fcf6e968259946eaf521ac3daac470e;hpb=00e4d4da1b2c00da139b09d3ed4ab9ad9fba2691 diff --git a/time.c b/time.c index 6e1d603d..0cb9babe 100644 --- a/time.c +++ b/time.c @@ -106,9 +106,10 @@ void tv_add(const struct timeval *a, const struct timeval *b, void tv_scale(const unsigned long mult, const struct timeval *tv, struct timeval *result) { - result->tv_sec = mult * tv->tv_sec; - result->tv_sec += tv->tv_usec * mult / 1000 / 1000; - result->tv_usec = tv->tv_usec * mult % (1000 * 1000); + uint64_t x = ((uint64_t)tv->tv_sec * 1000 * 1000 + tv->tv_usec) * mult; + + result->tv_sec = x / 1000 / 1000; + result->tv_usec = x % (1000 * 1000); } /**