+#ifdef _WIN32
+#define NS_PER_SEC 10000000LL
+/* Convert FILETIMEs into secs since the Epoch (Jan1-1970) */
+#define FT2longlong(ll,ft) \
+ (ll)=(ft).dwHighDateTime; \
+ (ll) <<= 32; \
+ (ll) |= (ft).dwLowDateTime; \
+ (ll) /= (unsigned long long) (NS_PER_SEC / CLOCKS_PER_SEC)
+#endif
+
+#ifdef _WIN32
+/* cygwin32 or mingw32 version */
+double
+elapsedtime(void)
+{
+ FILETIME creationTime, exitTime, kernelTime, userTime;
+ long long int kT, uT;
+
+
+ /* 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..*/
+ return 0;
+ }
+
+ FT2longlong(kT,kernelTime);
+ FT2longlong(uT,userTime);
+ return (((StgDouble)(uT + kT))/TicksPerSecond - ElapsedTimeStart);
+}
+
+#else
+