-/* elapsedtime() -- The current elapsed time in seconds */
-
-#if defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS)
-#define HNS_PER_SEC 10000000LL /* FILETIMES are in units of 100ns */
-/* Convert FILETIMEs into secs */
-#define FT2longlong(ll,ft) \
- (ll)=(ft).dwHighDateTime; \
- (ll) <<= 32; \
- (ll) |= (ft).dwLowDateTime; \
- (ll) /= (unsigned long long) (HNS_PER_SEC / CLOCKS_PER_SEC)
-#endif
-
-#if defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS)
-/* cygwin32 or mingw32 version */
-static void
-getTimes(void)
-{
- static int is_win9x = -1;
-
- FILETIME creationTime, exitTime, userTime, kernelTime = {0,0};
- long long int kT, uT;
-
- if (is_win9x < 0) {
- /* figure out whether we're on a Win9x box or not. */
- OSVERSIONINFO oi;
- BOOL b;
-
- /* Need to init the size field first.*/
- oi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- b = GetVersionEx(&oi);
-
- is_win9x = ( (b && (oi.dwPlatformId & VER_PLATFORM_WIN32_WINDOWS)) ? 1 : 0);
- }
-
- if (is_win9x) {
- /* On Win9x, just attribute all running time to the user. */
- SYSTEMTIME st;
-
- GetSystemTime(&st);
- SystemTimeToFileTime(&st,&userTime);
- } else {
- /* ToDo: pin down elapsed times to just the OS thread(s) that
- are evaluating/managing Haskell code.
- */
- if (!GetProcessTimes (GetCurrentProcess(), &creationTime,
- &exitTime, &kernelTime, &userTime)) {
- /* Probably on a Win95 box..*/
- CurrentElapsedTime = 0;
- CurrentUserTime = 0;
- return;
- }
- }
-
- FT2longlong(kT,kernelTime);
- FT2longlong(uT,userTime);
- CurrentElapsedTime = uT + kT;
- CurrentUserTime = uT;
-
- if (is_win9x) {
- /* Adjust for the fact that we're using system time & not
- process time on Win9x. */
- CurrentUserTime -= ElapsedTimeStart;
- CurrentElapsedTime -= ElapsedTimeStart;
- }
-}
-
-#else /* !win32 */
-
-static void
-getTimes(void)