2020-07-30 23:38:15 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-07-30 23:38:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <Kernel/Process.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-03-01 13:49:16 +01:00
|
|
|
KResultOr<clock_t> Process::sys$times(Userspace<tms*> user_times)
|
2020-07-30 23:38:15 +02:00
|
|
|
{
|
|
|
|
|
REQUIRE_PROMISE(stdio);
|
2020-08-09 12:26:56 -07:00
|
|
|
tms times = {};
|
|
|
|
|
times.tms_utime = m_ticks_in_user;
|
|
|
|
|
times.tms_stime = m_ticks_in_kernel;
|
|
|
|
|
times.tms_cutime = m_ticks_in_user_for_dead_children;
|
|
|
|
|
times.tms_cstime = m_ticks_in_kernel_for_dead_children;
|
|
|
|
|
|
2020-09-11 21:11:07 -06:00
|
|
|
if (!copy_to_user(user_times, ×))
|
2021-03-01 13:49:16 +01:00
|
|
|
return EFAULT;
|
2020-08-09 12:26:56 -07:00
|
|
|
|
2020-11-15 11:58:19 -07:00
|
|
|
return TimeManagement::the().uptime_ms() & 0x7fffffff;
|
2020-07-30 23:38:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|