Repository : ssh://darcs.haskell.org//srv/darcs/ghc On branch : master
http://hackage.haskell.org/trac/ghc/changeset/d0d0c36a99c588f47d530eae0e505e5a9d317339 >--------------------------------------------------------------- commit d0d0c36a99c588f47d530eae0e505e5a9d317339 Author: Ian Lynagh <[email protected]> Date: Sat May 26 11:41:12 2012 +0100 Fix problems with getMonotonicNSec on OS X We were incorrectly multiplying by 1e9, which (a) meant we were getting values that were far too large, and (b) meant that when we casted from double to StgWord64 the result was 0, as the value was out of range. We now do all the work as StgWord64. >--------------------------------------------------------------- rts/posix/GetTime.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git a/rts/posix/GetTime.c b/rts/posix/GetTime.c index da8d0fa..fabc404 100644 --- a/rts/posix/GetTime.c +++ b/rts/posix/GetTime.c @@ -34,7 +34,8 @@ // separately, using getrusage() and gettimeofday() respectively #ifdef darwin_HOST_OS -static double timer_scaling_factor_ns = 0.0; +static uint64_t timer_scaling_factor_numer = 0; +static uint64_t timer_scaling_factor_denom = 0; #endif void initializeTimer() @@ -42,7 +43,8 @@ void initializeTimer() #ifdef darwin_HOST_OS mach_timebase_info_data_t info; (void) mach_timebase_info(&info); - timer_scaling_factor_ns = (double)info.numer / (double)info.denom * 1e9; + timer_scaling_factor_numer = (uint64_t)info.numer; + timer_scaling_factor_denom = (uint64_t)info.denom; #endif } @@ -87,7 +89,7 @@ StgWord64 getMonotonicNSec(void) (StgWord64)ts.tv_nsec; #elif defined(darwin_HOST_OS) uint64_t time = mach_absolute_time(); - return (double)time * timer_scaling_factor_ns; + return (time * timer_scaling_factor_numer) / timer_scaling_factor_denom; #else struct timeval tv; _______________________________________________ Cvs-ghc mailing list [email protected] http://www.haskell.org/mailman/listinfo/cvs-ghc
