Skip to content

Commit

Permalink
deps: update to uvwasi 0.0.15
Browse files Browse the repository at this point in the history
Notable changes:

- Use GetThreadTimes() on Windows for CLOCK_THREAD_CPUTIME_ID.
- Increase the precision of the process and thread clocks on
  Windows.

PR-URL: #46253
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Jiawen Geng <[email protected]>
  • Loading branch information
cjihrig authored and ruyadorno committed Jan 31, 2023
1 parent 7cf0da0 commit 312e10c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
2 changes: 1 addition & 1 deletion deps/uvwasi/include/uvwasi.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extern "C" {

#define UVWASI_VERSION_MAJOR 0
#define UVWASI_VERSION_MINOR 0
#define UVWASI_VERSION_PATCH 14
#define UVWASI_VERSION_PATCH 15
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
(UVWASI_VERSION_MINOR << 8) | \
(UVWASI_VERSION_PATCH))
Expand Down
33 changes: 9 additions & 24 deletions deps/uvwasi/src/clocks.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,23 @@
#include "uv_mapping.h"


#define UVWASI__WIN_TIME_AND_RETURN(handle, time) \
#define UVWASI__WIN_TIME_AND_RETURN(handle, get_times, time) \
do { \
FILETIME create; \
FILETIME exit; \
FILETIME system; \
FILETIME user; \
SYSTEMTIME sys_system; \
SYSTEMTIME sys_user; \
if (0 == GetProcessTimes((handle), &create, &exit, &system, &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 Expand Up @@ -137,7 +122,7 @@ uvwasi_errno_t uvwasi__clock_gettime_realtime(uvwasi_timestamp_t* time) {

uvwasi_errno_t uvwasi__clock_gettime_process_cputime(uvwasi_timestamp_t* time) {
#if defined(_WIN32)
UVWASI__WIN_TIME_AND_RETURN(GetCurrentProcess(), *time);
UVWASI__WIN_TIME_AND_RETURN(GetCurrentProcess(), GetProcessTimes, *time);
#elif defined(CLOCK_PROCESS_CPUTIME_ID) && \
!defined(__APPLE__) && \
!defined(__sun)
Expand All @@ -150,7 +135,7 @@ uvwasi_errno_t uvwasi__clock_gettime_process_cputime(uvwasi_timestamp_t* time) {

uvwasi_errno_t uvwasi__clock_gettime_thread_cputime(uvwasi_timestamp_t* time) {
#if defined(_WIN32)
UVWASI__WIN_TIME_AND_RETURN(GetCurrentThread(), *time);
UVWASI__WIN_TIME_AND_RETURN(GetCurrentThread(), GetThreadTimes, *time);
#elif defined(__APPLE__)
UVWASI__OSX_THREADTIME_AND_RETURN(*time);
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun) && !defined(__PASE__)
Expand Down

0 comments on commit 312e10c

Please sign in to comment.