From 8ca6c9fff0449f0f4655043c7f1e07df92ef4dee Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 11 Oct 2018 13:57:43 +0300 Subject: [PATCH] Fix thread_base::get_cycles (Linux/POSIX) --- Utilities/Thread.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index d711febbf1..1b8be3b960 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -1880,8 +1880,9 @@ u64 thread_base::get_cycles() if (QueryThreadCycleTime((HANDLE)m_thread.load(), &cycles)) { #else + clockid_t _clock; struct timespec thread_time; - if (!clock_gettime(CLOCK_THREAD_CPUTIME_ID, &thread_time)) + if (!pthread_getcpuclockid((pthread_t)m_thread.load(), &_clock) && !clock_gettime(_clock, &thread_time)) { cycles = static_cast(thread_time.tv_sec) * 1'000'000'000 + thread_time.tv_nsec; #endif