Skip to content

Commit 8582f99

Browse files
cjihrigjuanarbol
authored andcommitted
deps: update to uvwasi 0.0.15
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 <yagiz@nizipli.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
1 parent f389b2f commit 8582f99

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

deps/uvwasi/include/uvwasi.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern "C" {
1010

1111
#define UVWASI_VERSION_MAJOR 0
1212
#define UVWASI_VERSION_MINOR 0
13-
#define UVWASI_VERSION_PATCH 14
13+
#define UVWASI_VERSION_PATCH 15
1414
#define UVWASI_VERSION_HEX ((UVWASI_VERSION_MAJOR << 16) | \
1515
(UVWASI_VERSION_MINOR << 8) | \
1616
(UVWASI_VERSION_PATCH))

deps/uvwasi/src/clocks.c

+9-24
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,23 @@
1111
#include "uv_mapping.h"
1212

1313

14-
#define UVWASI__WIN_TIME_AND_RETURN(handle, time) \
14+
#define UVWASI__WIN_TIME_AND_RETURN(handle, get_times, time) \
1515
do { \
1616
FILETIME create; \
1717
FILETIME exit; \
1818
FILETIME system; \
1919
FILETIME user; \
20-
SYSTEMTIME sys_system; \
21-
SYSTEMTIME sys_user; \
22-
if (0 == GetProcessTimes((handle), &create, &exit, &system, &user)) { \
20+
if (0 == get_times((handle), &create, &exit, &system, &user)) { \
2321
return uvwasi__translate_uv_error( \
2422
uv_translate_sys_error(GetLastError()) \
2523
); \
2624
} \
2725
\
28-
if (0 == FileTimeToSystemTime(&system, &sys_system)) { \
29-
return uvwasi__translate_uv_error( \
30-
uv_translate_sys_error(GetLastError()) \
31-
); \
32-
} \
33-
\
34-
if (0 == FileTimeToSystemTime(&user, &sys_user)) { \
35-
return uvwasi__translate_uv_error( \
36-
uv_translate_sys_error(GetLastError()) \
37-
); \
38-
} \
39-
\
40-
(time) = (((uvwasi_timestamp_t)(sys_system.wHour * 3600) + \
41-
(sys_system.wMinute * 60) + sys_system.wSecond) * NANOS_PER_SEC) + \
42-
((uvwasi_timestamp_t)(sys_system.wMilliseconds) * 1000000) + \
43-
(((uvwasi_timestamp_t)(sys_user.wHour * 3600) + \
44-
(sys_user.wMinute * 60) + sys_user.wSecond) * NANOS_PER_SEC) + \
45-
((uvwasi_timestamp_t)(sys_user.wMilliseconds) * 1000000); \
26+
/* FILETIME times are in units of 100 nanoseconds */ \
27+
(time) = (((uvwasi_timestamp_t) \
28+
system.dwHighDateTime << 32 | system.dwLowDateTime) * 100 + \
29+
((uvwasi_timestamp_t) \
30+
user.dwHighDateTime << 32 | user.dwLowDateTime) * 100); \
4631
return UVWASI_ESUCCESS; \
4732
} while (0)
4833

@@ -137,7 +122,7 @@ uvwasi_errno_t uvwasi__clock_gettime_realtime(uvwasi_timestamp_t* time) {
137122

138123
uvwasi_errno_t uvwasi__clock_gettime_process_cputime(uvwasi_timestamp_t* time) {
139124
#if defined(_WIN32)
140-
UVWASI__WIN_TIME_AND_RETURN(GetCurrentProcess(), *time);
125+
UVWASI__WIN_TIME_AND_RETURN(GetCurrentProcess(), GetProcessTimes, *time);
141126
#elif defined(CLOCK_PROCESS_CPUTIME_ID) && \
142127
!defined(__APPLE__) && \
143128
!defined(__sun)
@@ -150,7 +135,7 @@ uvwasi_errno_t uvwasi__clock_gettime_process_cputime(uvwasi_timestamp_t* time) {
150135

151136
uvwasi_errno_t uvwasi__clock_gettime_thread_cputime(uvwasi_timestamp_t* time) {
152137
#if defined(_WIN32)
153-
UVWASI__WIN_TIME_AND_RETURN(GetCurrentThread(), *time);
138+
UVWASI__WIN_TIME_AND_RETURN(GetCurrentThread(), GetThreadTimes, *time);
154139
#elif defined(__APPLE__)
155140
UVWASI__OSX_THREADTIME_AND_RETURN(*time);
156141
#elif defined(CLOCK_THREAD_CPUTIME_ID) && !defined(__sun) && !defined(__PASE__)

0 commit comments

Comments
 (0)