From 80831550a79cf6b01ef53c41408787df203aca04 Mon Sep 17 00:00:00 2001 From: woachk <24752637+woachk@users.noreply.github.com> Date: Sun, 11 Nov 2018 22:06:27 +0100 Subject: [PATCH] Use the shared rusage_get_current() implementation for consistency Oops. --- kernel/time.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/kernel/time.c b/kernel/time.c index ebdfb048..b39314ed 100644 --- a/kernel/time.c +++ b/kernel/time.c @@ -112,19 +112,9 @@ dword_t sys_times( addr_t tbuf) { STRACE("times(0x%x)", tbuf); if (tbuf) { struct tms tmp; -#if __linux__ - struct rusage usage; - int err = getrusage(RUSAGE_THREAD, &usage); - assert(err == 0); - tmp.tms_utime = usage.ru_utime.tv_usec * (CLOCKS_PER_SEC/1000); - tmp.tms_stime = usage.ru_stime.tv_usec * (CLOCKS_PER_SEC/1000); -#elif __APPLE__ - thread_basic_info_data_t info; - mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT; - int err = thread_info(mach_thread_self(), THREAD_BASIC_INFO, (thread_info_t) &info, &count); - tmp.tms_utime = info.user_time.microseconds * (CLOCKS_PER_SEC/1000); - tmp.tms_stime = info.system_time.microseconds * (CLOCKS_PER_SEC/1000); -#endif + struct rusage_ rusage = rusage_get_current(); + tmp.tms_utime = rusage.utime.usec * (CLOCKS_PER_SEC/1000); + tmp.tms_stime = rusage.stime.usec * (CLOCKS_PER_SEC/1000); if (user_put(tbuf, tmp)) return _EFAULT; }