From dc7a61aa17e786ceeadf5eb6f854372630456267 Mon Sep 17 00:00:00 2001 From: Yonggang Luo Date: Wed, 30 Mar 2022 04:32:39 +0800 Subject: [PATCH] util: Implement util_thread_get_time_nano on win32 Signed-off-by: Yonggang Luo Reviewed-by: Jesse Natalie Part-of: --- src/util/u_thread.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/util/u_thread.h b/src/util/u_thread.h index c25067930b2..f2187e551dd 100644 --- a/src/util/u_thread.h +++ b/src/util/u_thread.h @@ -240,6 +240,13 @@ util_thread_get_time_nano(thrd_t thread) pthread_getcpuclockid(thread, &cid); clock_gettime(cid, &ts); return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec; +#elif defined(_WIN32) + union { + FILETIME time; + ULONGLONG value; + } kernel_time, user_time; + GetThreadTimes((HANDLE)thread.handle, NULL, NULL, &kernel_time.time, &user_time.time); + return (kernel_time.value + user_time.value) * 100; #else (void)thread; return 0;