Skip to content

Commit

Permalink
Increase precision of clocks in clock_time_get on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
ospencer committed Jan 15, 2023
1 parent d16ebe6 commit 55f4eb6
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/clocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,17 @@
FILETIME exit; \
FILETIME system; \
FILETIME user; \
SYSTEMTIME sys_system; \
SYSTEMTIME sys_user; \
if (0 == get_times((handle), &create, &exit, &system, &user)) { \
return uvwasi__translate_uv_error( \
uv_translate_sys_error(GetLastError()) \
); \
} \
\
if (0 == FileTimeToSystemTime(&system, &sys_system)) { \
return uvwasi__translate_uv_error( \
uv_translate_sys_error(GetLastError()) \
); \
} \
\
if (0 == FileTimeToSystemTime(&user, &sys_user)) { \
return uvwasi__translate_uv_error( \
uv_translate_sys_error(GetLastError()) \
); \
} \
\
(time) = (((uvwasi_timestamp_t)(sys_system.wHour * 3600) + \
(sys_system.wMinute * 60) + sys_system.wSecond) * NANOS_PER_SEC) + \
((uvwasi_timestamp_t)(sys_system.wMilliseconds) * 1000000) + \
(((uvwasi_timestamp_t)(sys_user.wHour * 3600) + \
(sys_user.wMinute * 60) + sys_user.wSecond) * NANOS_PER_SEC) + \
((uvwasi_timestamp_t)(sys_user.wMilliseconds) * 1000000); \
/* FILETIME times are in units of 100 nanoseconds */ \
(time) = (((uvwasi_timestamp_t) \
system.dwHighDateTime << 32 | system.dwLowDateTime) * 100 + \
((uvwasi_timestamp_t) \
user.dwHighDateTime << 32 | user.dwLowDateTime) * 100); \
return UVWASI_ESUCCESS; \
} while (0)

Expand Down

0 comments on commit 55f4eb6

Please sign in to comment.