headers/bsd: Add sys/queue.h.
[haiku.git] / src / system / libroot / posix / sys / getrusage.c
blobdf56ece99a930f091493b94856a109861395f79b
1 /*
2 ** Copyright 2004, Jérôme Duval, jerome.duval@free.fr.
3 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
4 ** Distributed under the terms of the MIT License.
5 */
7 #include <OS.h>
8 #include <sys/resource.h>
9 #include <errno.h>
11 #include <errno_private.h>
14 int
15 getrusage(int who, struct rusage *rusage)
17 team_usage_info info;
19 if (get_team_usage_info(B_CURRENT_TEAM, who, &info) != B_OK) {
20 __set_errno(B_BAD_VALUE);
21 return -1;
24 rusage->ru_utime.tv_sec = info.user_time / 1000000;
25 rusage->ru_utime.tv_usec = info.user_time % 1000000;
27 rusage->ru_stime.tv_sec = info.kernel_time / 1000000;
28 rusage->ru_stime.tv_usec = info.kernel_time % 1000000;
30 return 0;