From f84b2a908a8fd897f80e290a3814dc17dd4ea727 Mon Sep 17 00:00:00 2001 From: rrt Date: Thu, 6 Apr 2000 17:54:01 +0000 Subject: [PATCH] [project @ 2000-04-06 17:54:01 by rrt] Fixed getCPUTime for Windows, which was seriously broken (arithmetically, logically &c. &c.). showTime now calls tzset under Cygwin just as timezone.c does. --- ghc/lib/std/cbits/getCPUTime.c | 10 +++++----- ghc/lib/std/cbits/showTime.c | 6 +++++- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ghc/lib/std/cbits/getCPUTime.c b/ghc/lib/std/cbits/getCPUTime.c index 512aa57..34f1b37 100644 --- a/ghc/lib/std/cbits/getCPUTime.c +++ b/ghc/lib/std/cbits/getCPUTime.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: getCPUTime.c,v 1.6 1999/09/30 15:50:02 sof Exp $ + * $Id: getCPUTime.c,v 1.7 2000/04/06 17:54:01 rrt Exp $ * * getCPUTime Runtime Support */ @@ -155,11 +155,11 @@ getCPUTime(StgByteArray cpuStruct) FT2usecs(uT, userTime); FT2usecs(kT, kernelTime); - + cpu[0] = (unsigned int)(uT / NS_PER_SEC); - cpu[1] = (unsigned int)(uT * 100); - cpu[0] = (unsigned int)(kT / NS_PER_SEC); - cpu[1] = (unsigned int)(kT * 100); + cpu[1] = (unsigned int)((uT - cpu[0] * NS_PER_SEC) * 100); + cpu[2] = (unsigned int)(kT / NS_PER_SEC); + cpu[3] = (unsigned int)((kT - cpu[2] * NS_PER_SEC) * 100); return 1; } diff --git a/ghc/lib/std/cbits/showTime.c b/ghc/lib/std/cbits/showTime.c index 3e16699..43fd6c8 100644 --- a/ghc/lib/std/cbits/showTime.c +++ b/ghc/lib/std/cbits/showTime.c @@ -1,7 +1,7 @@ /* * (c) The GRASP/AQUA Project, Glasgow University, 1994-1998 * - * $Id: showTime.c,v 1.7 1999/11/23 12:19:20 simonmar Exp $ + * $Id: showTime.c,v 1.8 2000/04/06 17:54:01 rrt Exp $ * * ClockTime.showsPrec Runtime Support */ @@ -41,6 +41,10 @@ showTime(I_ size, StgByteArray d, I_ maxsize, StgByteArray buf) return (-1); } tm = localtime(&t); +#ifdef cygwin32_TARGET_OS + /* Same as in timezone.c: tzset() isn't called automatically */ + tzset(); +#endif if (tm != NULL && strftime(buf, maxsize, "%a %b %d %H:%M:%S %Z %Y", tm) > 0) { return 1; } else { -- 1.7.10.4