Commit fb0730f1 by Tobias Nießen

util: use 64 bit timer on Windows

git__timer was originally implemented using a 32 bit timer since
Windows XP did not support GetTickCount64. Windows XP was discontinued
five years ago, so it should be safe to use the new API.

As a benefit, we do not need to care about overflows for the next 585
million years.
parent 75cc755f
...@@ -361,22 +361,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size) ...@@ -361,22 +361,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size)
GIT_INLINE(double) git__timer(void) GIT_INLINE(double) git__timer(void)
{ {
/* We need the initial tick count to detect if the tick /* GetTickCount64 returns the number of milliseconds that have
* count has rolled over. */
static DWORD initial_tick_count = 0;
/* GetTickCount returns the number of milliseconds that have
* elapsed since the system was started. */ * elapsed since the system was started. */
DWORD count = GetTickCount(); return (double) GetTickCount64() / (double) 1000;
if(initial_tick_count == 0) {
initial_tick_count = count;
} else if (count < initial_tick_count) {
/* The tick count has rolled over - adjust for it. */
count = (0xFFFFFFFF - initial_tick_count) + count;
}
return (double) count / (double) 1000;
} }
#elif __APPLE__ #elif __APPLE__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment