From ecde6d2dcf12d9c5bf0d275bd13fedd1f84d5148 Mon Sep 17 00:00:00 2001 From: gbcwbz Date: Sun, 5 Jun 2022 22:51:22 +0800 Subject: [PATCH] [libc][time] Fix clock_gettime for CLOCK_CPUTIME_ID (#6029) --- components/libc/compilers/common/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/libc/compilers/common/time.c b/components/libc/compilers/common/time.c index 63b4746618..16387148f6 100644 --- a/components/libc/compilers/common/time.c +++ b/components/libc/compilers/common/time.c @@ -616,8 +616,8 @@ int clock_gettime(clockid_t clockid, struct timespec *tp) unit = clock_cpu_getres(); cpu_tick = clock_cpu_gettime(); - tp->tv_sec = ((int)(cpu_tick * unit)) / NANOSECOND_PER_SECOND; - tp->tv_nsec = ((int)(cpu_tick * unit)) % NANOSECOND_PER_SECOND; + tp->tv_sec = ((long long)(cpu_tick * unit)) / NANOSECOND_PER_SECOND; + tp->tv_nsec = ((long long)(cpu_tick * unit)) % NANOSECOND_PER_SECOND; } break; #endif -- GitLab