1 /* Return the CPU time used by the program so far. Hurd version.
2 Copyright (C) 2001-2024 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, see
17 <https://www.gnu.org/licenses/>. */
22 #include <mach/task_info.h>
25 /* Return the time used by the program so far (user time + system time). */
29 struct task_basic_info bi
;
30 struct task_thread_times_info tti
;
31 mach_msg_type_number_t count
;
35 count
= TASK_BASIC_INFO_COUNT
;
36 err
= __task_info (__mach_task_self (), TASK_BASIC_INFO
,
37 (task_info_t
) &bi
, &count
);
39 return __hurd_fail (err
);
41 count
= TASK_THREAD_TIMES_INFO_COUNT
;
42 err
= __task_info (__mach_task_self (), TASK_THREAD_TIMES_INFO
,
43 (task_info_t
) &tti
, &count
);
45 return __hurd_fail (err
);
47 total
= bi
.user_time
.seconds
* 1000000 + bi
.user_time
.microseconds
;
48 total
+= tti
.user_time
.seconds
* 1000000 + tti
.user_time
.microseconds
;
49 total
+= bi
.system_time
.seconds
* 1000000 + bi
.system_time
.microseconds
;
50 total
+= tti
.system_time
.seconds
* 1000000 + tti
.system_time
.microseconds
;