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 */ 6 7 #include <OS.h> 8 #include <sys/resource.h> 9 #include <errno.h> 10 11 12 int 13 getrusage(int who, struct rusage *rusage) 14 { 15 team_usage_info info; 16 17 if (get_team_usage_info(B_CURRENT_TEAM, who, &info) != B_OK) { 18 errno = B_BAD_VALUE; 19 return -1; 20 } 21 22 rusage->ru_utime.tv_sec = info.user_time / 1000000; 23 rusage->ru_utime.tv_usec = info.user_time % 1000000; 24 25 rusage->ru_stime.tv_sec = info.kernel_time / 1000000; 26 rusage->ru_stime.tv_usec = info.kernel_time % 1000000; 27 28 return 0; 29 } 30 31