diff options
author | Tobias Nießen <tniessen@tnie.de> | 2019-04-16 23:49:16 +0200 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2019-07-29 18:06:48 +0200 |
commit | fb0730f1f3957b41fa0dd2594fb7d0214b2594da (patch) | |
tree | 79f88cdb12bb9114034a6275be1ac7fa272614fe | |
parent | 75cc755fc56c6aca0252f02b0abde859efeb0132 (diff) | |
download | libgit2-fb0730f1f3957b41fa0dd2594fb7d0214b2594da.tar.gz |
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.
-rw-r--r-- | src/util.h | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/util.h b/src/util.h index b9ab65273..6f49653a4 100644 --- a/src/util.h +++ b/src/util.h @@ -361,22 +361,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size) GIT_INLINE(double) git__timer(void) { - /* We need the initial tick count to detect if the tick - * count has rolled over. */ - static DWORD initial_tick_count = 0; - - /* GetTickCount returns the number of milliseconds that have + /* GetTickCount64 returns the number of milliseconds that have * elapsed since the system was started. */ - DWORD count = GetTickCount(); - - 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; + return (double) GetTickCount64() / (double) 1000; } #elif __APPLE__ |