libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / libroot / posix / sys / times.cpp
blob54e3f11dde752ed359f2825947cedc082db55e4d
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 */
7 #include <OS.h>
9 #include <errno.h>
10 #include <sys/resource.h>
11 #include <sys/times.h>
13 #include <symbol_versioning.h>
15 #include <errno_private.h>
16 #include <time_private.h>
17 #include <times_private.h>
20 static inline clock_t
21 times_common(struct tms* buffer, bigtime_t microSecondsPerClock)
23 team_usage_info info;
24 status_t err;
26 if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_SELF, &info))
27 != B_OK) {
28 __set_errno(err);
29 return -1;
32 buffer->tms_utime = info.user_time / microSecondsPerClock;
33 buffer->tms_stime = info.kernel_time / microSecondsPerClock;
35 if ((err = get_team_usage_info(B_CURRENT_TEAM, RUSAGE_CHILDREN, &info))
36 != B_OK) {
37 __set_errno(err);
38 return -1;
41 buffer->tms_cutime = info.user_time / microSecondsPerClock;
42 buffer->tms_cstime = info.kernel_time / microSecondsPerClock;
44 return system_time() / microSecondsPerClock;
48 clock_t
49 __times_beos(struct tms* buffer)
51 return times_common(buffer, MICROSECONDS_PER_CLOCK_TICK_BEOS);
55 clock_t
56 __times(struct tms* buffer)
58 return times_common(buffer, MICROSECONDS_PER_CLOCK_TICK);
62 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__times_beos", "times@", "BASE");
64 DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("__times", "times@@", "1_ALPHA4");