1 /* Return the CPU time used by the program so far. Hurd version.
2 Copyright (C) 2001 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 #include <mach/task_info.h>
26 /* Return the time used by the program so far (user time + system time). */
30 struct task_basic_info bi
;
31 struct task_thread_times_info tti
;
32 mach_msg_type_number_t count
;
36 count
= TASK_BASIC_INFO_COUNT
;
37 err
= __task_info (__mach_task_self (), TASK_BASIC_INFO
,
38 (task_info_t
) &bi
, &count
);
40 return __hurd_fail (err
);
42 count
= TASK_THREAD_TIMES_INFO_COUNT
;
43 err
= __task_info (__mach_task_self (), TASK_THREAD_TIMES_INFO
,
44 (task_info_t
) &tti
, &count
);
46 return __hurd_fail (err
);
48 total
= bi
.user_time
.seconds
* 1000000 + bi
.user_time
.microseconds
;
49 total
+= tti
.user_time
.seconds
* 1000000 + tti
.user_time
.microseconds
;
50 total
+= bi
.system_time
.seconds
* 1000000 + bi
.system_time
.microseconds
;
51 total
+= tti
.system_time
.seconds
* 1000000 + tti
.system_time
.microseconds
;