From: simonmar Date: Thu, 3 Nov 2005 13:39:22 +0000 (+0000) Subject: [project @ 2005-11-03 13:39:22 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~80 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=57fadb77f1643b9096132a45adfde4cf3e7abdcf;p=ghc-hetmet.git [project @ 2005-11-03 13:39:22 by simonmar] Fix build on win32. --- diff --git a/ghc/rts/win32/GetTime.c b/ghc/rts/win32/GetTime.c index a5a89d9..6b50211 100644 --- a/ghc/rts/win32/GetTime.c +++ b/ghc/rts/win32/GetTime.c @@ -11,6 +11,10 @@ #include +#ifdef HAVE_TIME_H +# include +#endif + /* elapsedtime() -- The current elapsed time in seconds */ #define HNS_PER_SEC 10000000LL /* FILETIMES are in units of 100ns */ @@ -20,13 +24,13 @@ (ll) <<= 32; \ (ll) |= (ft).dwLowDateTime; \ (ll) /= (unsigned long long) (HNS_PER_SEC / CLOCKS_PER_SEC) -#endif /* cygwin32 or mingw32 version */ -static void +void getProcessTimes( Ticks *user, Ticks *elapsed ) { static int is_win9x = -1; + static Ticks elapsed_start = 0; FILETIME creationTime, exitTime, userTime, kernelTime = {0,0}; long long int kT, uT; @@ -68,10 +72,12 @@ getProcessTimes( Ticks *user, Ticks *elapsed ) *user = uT; if (is_win9x) { - /* Adjust for the fact that we're using system time & not - process time on Win9x. */ - *user -= ElapsedTimeStart; - *elapsed -= ElapsedTimeStart; + /* User time is assumed to start at zero, so adjust for the fact + that we're using system time & not process time on Win9x. */ + if (elapsed_start == 0) { + elapsed_start = *elapsed; + } + *user -= elapsed_start; } } @@ -82,7 +88,7 @@ Ticks getProcessCPUTime(void) return user; } -Ticks getProcessElapsedTime(void); +Ticks getProcessElapsedTime(void) { Ticks user, elapsed; getProcessTimes(&user,&elapsed);