Skip to content

Commit

Permalink
fixup! Benchmark: emulate clock_gettime(2) on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aklomp committed Jan 8, 2024
1 parent c514a9c commit 51c5779
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/gettime_win.c
Expand Up @@ -19,14 +19,14 @@ xgetfiletime (void)
// Return the current time in UTC as a 64-bit value representing the
// number of 100-nanosecond intervals since January 1, 1601.
GetSystemTimePreciseAsFileTime(&current_time_ft);
current_time.LowPart = current_time_ft.dwLowDateTime;
current_time.LowPart = current_time_ft.dwLowDateTime;
current_time.HighPart = current_time_ft.dwHighDateTime;

return current_time;
}

static int
clock_gettime (clock_t id, struct timespec* ts)
clock_gettime (const int id, struct timespec* ts)
{
if (id != CLOCK_REALTIME) {
return -1;
Expand All @@ -35,7 +35,7 @@ clock_gettime (clock_t id, struct timespec* ts)
ULARGE_INTEGER current_time = xgetfiletime();

// Time from Epoch to now.
ts->tv_sec = (current_time.QuadPart - UNIX_EPOCH) / 10000000;
ts->tv_sec = (current_time.QuadPart - UNIX_EPOCH) / 10000000;
ts->tv_nsec = ((current_time.QuadPart - UNIX_EPOCH) % 10000000) * 100;

return 0;
Expand Down

0 comments on commit 51c5779

Please sign in to comment.