source:
rtems/cpukit/libcsupport/src/__times.c
@
b43314a
Last change on this file since b43314a was b43314a, checked in by Joel Sherrill <joel.sherrill@…>, on 06/28/02 at 18:51:35 | |
---|---|
|
|
File size: 1.4 KB |
Rev | Line | |
---|---|---|
[ac7d5ef0] | 1 | /* |
[07a3253d] | 2 | * times() - POSIX 1003.1b 4.5.2 - Get Process Times |
[ac7d5ef0] | 3 | * |
[08311cc3] | 4 | * COPYRIGHT (c) 1989-1999. |
[ac7d5ef0] | 5 | * On-Line Applications Research Corporation (OAR). |
6 | * | |
[98e4ebf5] | 7 | * The license and distribution terms for this file may be |
8 | * found in the file LICENSE in this distribution or at | |
[03f2154e] | 9 | * http://www.OARcorp.com/rtems/license.html. |
[ac7d5ef0] | 10 | * |
11 | * $Id$ | |
12 | */ | |
13 | ||
[9c49db4] | 14 | #if HAVE_CONFIG_H |
15 | #include "config.h" | |
16 | #endif | |
17 | ||
[ac7d5ef0] | 18 | #include <rtems.h> |
19 | ||
20 | #include <sys/times.h> | |
21 | #include <time.h> | |
22 | #include <sys/time.h> | |
23 | #include <errno.h> | |
24 | #include <assert.h> | |
25 | ||
26 | clock_t _times( | |
27 | struct tms *ptms | |
28 | ) | |
29 | { | |
[07a3253d] | 30 | rtems_status_code status; |
31 | rtems_interval ticks; | |
[ac7d5ef0] | 32 | |
33 | if ( !ptms ) { | |
34 | errno = EFAULT; | |
35 | return -1; | |
36 | } | |
37 | ||
38 | /* | |
[b43314a] | 39 | * RTEMS technically has no notion of system versus user time |
40 | * since there is no separation of OS from application tasks. | |
41 | * But we can at least make a distinction between the number | |
42 | * of ticks since boot and the number of ticks executed by this | |
43 | * this thread. | |
[ac7d5ef0] | 44 | */ |
45 | ||
[b43314a] | 46 | ptms->tms_utime = _Thread_Executing->ticks_executed; |
47 | ptms->tms_stime = ticks; | |
[ac7d5ef0] | 48 | ptms->tms_cutime = 0; |
49 | ptms->tms_cstime = 0; | |
50 | ||
[b43314a] | 51 | return ticks; |
[ac7d5ef0] | 52 | } |
53 | ||
[07a3253d] | 54 | /* |
55 | * times() | |
56 | * | |
57 | * times() system call wrapper for _times() above. | |
58 | */ | |
59 | ||
[ac7d5ef0] | 60 | clock_t times( |
61 | struct tms *ptms | |
62 | ) | |
63 | { | |
64 | return _times( ptms ); | |
65 | } | |
66 | ||
[07a3253d] | 67 | /* |
68 | * _times_r | |
69 | * | |
70 | * This is the Newlib dependent reentrant version of times(). | |
71 | */ | |
72 | ||
[421dfef6] | 73 | #if defined(RTEMS_NEWLIB) |
[07a3253d] | 74 | |
75 | #include <reent.h> | |
76 | ||
[3294650] | 77 | clock_t _times_r( |
78 | struct _reent *ptr, | |
79 | struct tms *ptms | |
80 | ) | |
81 | { | |
[07a3253d] | 82 | return _times( ptms ); |
[3294650] | 83 | } |
[421dfef6] | 84 | #endif |
Note: See TracBrowser
for help on using the repository browser.