1 /* 2 ** Copyright 2004, Jérôme Duval, jerome.duval@free.fr. 3 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. 4 ** Distributed under the terms of the MIT License. 5 */ 6 7 #include <OS.h> 8 9 #include <errno.h> 10 #include <sys/resource.h> 11 #include <sys/times.h> 12 13 #include <symbol_versioning.h> 14 15 #include <time_private.h> 16 #include <times_private.h> 17 18 19 static inline clock_t 20 times_common(struct tms* buffer, bigtime_t microSecondsPerClock) 21 { 22 team_usage_info info; 23 status_t err; 24 25 if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info)) 26 != B_OK) { 27 errno = err; 28 return -1; 29 } 30 31 buffer->tms_utime = info.user_time / microSecondsPerClock; 32 buffer->tms_stime = info.kernel_time / microSecondsPerClock; 33 34 if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info)) 35 != B_OK) { 36 errno = err; 37 return -1; 38 } 39 40 buffer->tms_cutime = info.user_time / microSecondsPerClock; 41 buffer->tms_cstime = info.kernel_time / microSecondsPerClock; 42 43 return system_time() / microSecondsPerClock; 44 } 45 46 47 clock_t 48 __times_beos(struct tms* buffer) 49 { 50 return times_common(buffer, MICROSECONDS_PER_CLOCK_TICK_BEOS); 51 } 52 53 54 clock_t 55 __times(struct tms* buffer) 56 { 57 return times_common(buffer, MICROSECONDS_PER_CLOCK_TICK); 58 } 59 60 61 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__times_beos", "times@", "BASE"); 62 63 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__times", "times@@", "1_ALPHA4"); 64