From: Simon Marlow Date: Wed, 14 Feb 2007 16:17:19 +0000 (+0000) Subject: fix to getUSecOfDay(): arithmetic was overflowing X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=03cd9c09ff147ae19616ac65d3c0305329818c92;p=ghc-base.git fix to getUSecOfDay(): arithmetic was overflowing --- diff --git a/include/HsBase.h b/include/HsBase.h index 09693cb..45e2d39 100644 --- a/include/HsBase.h +++ b/include/HsBase.h @@ -724,7 +724,10 @@ INLINE HsWord64 getUSecOfDay(void) { struct timeval tv; gettimeofday(&tv, (struct timezone *) NULL); - return (tv.tv_sec * 1000000 + tv.tv_usec); + // Don't forget to cast *before* doing the arithmetic, otherwise + // the arithmetic happens at the type of tv_sec, which is probably + // only 'int'. + return ((HsWord64)tv.tv_sec * 1000000 + (HsWord64)tv.tv_usec); } INLINE void setTimevalTicks(struct timeval *p, HsWord64 usecs)