Skip to content

Commit 6031978

Browse files
authored
Merge pull request libgit2#5054 from tniessen/util-use-64-bit-timer
util: use 64 bit timer on Windows
2 parents feac594 + 071750a commit 6031978

File tree

3 files changed

+7
-17
lines changed

3 files changed

+7
-17
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,11 @@ ELSE ()
263263
ENDIF ()
264264
ENDIF()
265265

266+
# Ensure that MinGW provides the correct header files.
267+
IF (WIN32 AND NOT CYGWIN)
268+
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600)
269+
ENDIF()
270+
266271
IF( NOT CMAKE_CONFIGURATION_TYPES )
267272
# Build Debug by default
268273
IF (NOT CMAKE_BUILD_TYPE)

src/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ FILE(GLOB SRC_H
299299

300300
# On Windows use specific platform sources
301301
IF (WIN32 AND NOT CYGWIN)
302-
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600)
303-
304302
IF(MSVC)
305303
SET(WIN_RC "win32/git2.rc")
306304
ENDIF()

src/util.h

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -357,22 +357,9 @@ GIT_INLINE(void) git__memzero(void *data, size_t size)
357357

358358
GIT_INLINE(double) git__timer(void)
359359
{
360-
/* We need the initial tick count to detect if the tick
361-
* count has rolled over. */
362-
static DWORD initial_tick_count = 0;
363-
364-
/* GetTickCount returns the number of milliseconds that have
360+
/* GetTickCount64 returns the number of milliseconds that have
365361
* elapsed since the system was started. */
366-
DWORD count = GetTickCount();
367-
368-
if(initial_tick_count == 0) {
369-
initial_tick_count = count;
370-
} else if (count < initial_tick_count) {
371-
/* The tick count has rolled over - adjust for it. */
372-
count = (0xFFFFFFFF - initial_tick_count) + count;
373-
}
374-
375-
return (double) count / (double) 1000;
362+
return (double) GetTickCount64() / (double) 1000;
376363
}
377364

378365
#elif __APPLE__

0 commit comments

Comments
 (0)