summaryrefslogtreecommitdiff
path: root/libraries/base/cbits/Win32Utils.c
diff options
context:
space:
mode:
authorPaolo Capriotti <p.capriotti@gmail.com>2012-05-08 13:06:12 +0100
committerPaolo Capriotti <p.capriotti@gmail.com>2012-05-08 13:06:12 +0100
commitc031aecaee64e8df450ade287e0ddf44ff04b600 (patch)
treecda13ebd53a95859b6a86091064a3288e750fedc /libraries/base/cbits/Win32Utils.c
parent8dda2dfb3d1e668e9e1323d2534151069ca099e5 (diff)
downloadhaskell-c031aecaee64e8df450ade287e0ddf44ff04b600.tar.gz
Use RTS version of getMonotonicNSec on Windows (#6061)
Diffstat (limited to 'libraries/base/cbits/Win32Utils.c')
-rw-r--r--libraries/base/cbits/Win32Utils.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/libraries/base/cbits/Win32Utils.c b/libraries/base/cbits/Win32Utils.c
index 84b6b690ee..c084bd3a75 100644
--- a/libraries/base/cbits/Win32Utils.c
+++ b/libraries/base/cbits/Win32Utils.c
@@ -110,50 +110,4 @@ void maperrno (void)
errno = EINVAL;
}
-// Number of ticks per second used by the QueryPerformanceFrequency
-// implementaiton, represented by a 64-bit union type.
-static LARGE_INTEGER qpc_frequency = {.QuadPart = 0};
-
-// Initialize qpc_frequency. This function should be called before any call to
-// getMonotonicUSec. If QPC is not supported on this system, qpc_frequency is
-// set to 0.
-void initializeTimer()
-{
- BOOL qpc_supported = QueryPerformanceFrequency(&qpc_frequency);
- if (!qpc_supported)
- {
- qpc_frequency.QuadPart = 0;
- }
-}
-
-HsWord64 getMonotonicUSec()
-{
- if (qpc_frequency.QuadPart)
- {
- // system_time is a 64-bit union type used to represent the
- // tick count returned by QueryPerformanceCounter
- LARGE_INTEGER system_time;
-
- // get the tick count.
- QueryPerformanceCounter(&system_time);
-
- // compute elapsed seconds as double
- double secs = (double)system_time.QuadPart /
- (double)qpc_frequency.QuadPart;
-
- // return elapsed time in microseconds
- return (HsWord64)(secs * 1e6);
- }
- else // fallback to GetTickCount
- {
- // NOTE: GetTickCount is a 32-bit millisecond value, so it wraps around
- // every 49 days.
- DWORD count = GetTickCount();
-
- // getTickCount is in milliseconds, so multiply it by 1000 to get
- // microseconds.
- return (HsWord64)count * 1000;
- }
-}
-
#endif