Implemented times

now uses system_time, because we don't have to return a real time


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10242 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2004-11-25 20:16:35 +00:00
parent 4693e9c7a5
commit 82f223ea8c

View File

@ -1,24 +1,39 @@
/*
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the Haiku License.
** Copyright 2004, Jérô Duval, jerome.duval@free.fr.
** Copyright 2004, Axel Dörfler, axeld@pinc-software.de.
** Distributed under the terms of the MIT License.
*/
#include <OS.h>
#include <errno.h>
#include <sys/resource.h>
#include <sys/times.h>
#include <time.h>
clock_t
times(struct tms *buffer)
{
// ToDo: get some real values here!
buffer->tms_utime = 0;
buffer->tms_stime = 0;
buffer->tms_cutime = 0;
buffer->tms_cstime = 0;
team_usage_info info;
status_t err;
int32 clk_tck = 1000000 / CLK_TCK; /* to avoid overflow */
return real_time_clock() * CLK_TCK;
if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info)) != B_OK) {
errno = err;
return -1;
}
buffer->tms_utime = info.user_time / clk_tck;
buffer->tms_stime = info.kernel_time / clk_tck;
if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info)) != B_OK) {
errno = err;
return -1;
}
buffer->tms_cutime = info.user_time / clk_tck;
buffer->tms_cstime = info.kernel_time / clk_tck;
return system_time() / clk_tck;
}