4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * times() - POSIX 1003.1b 4.5.2 - Get Process Times |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-1999. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.OARcorp.com/rtems/license.html. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #include <rtems.h> |
---|
15 | |
---|
16 | #include <sys/times.h> |
---|
17 | #include <time.h> |
---|
18 | #include <sys/time.h> |
---|
19 | #include <errno.h> |
---|
20 | #include <assert.h> |
---|
21 | |
---|
22 | clock_t _times( |
---|
23 | struct tms *ptms |
---|
24 | ) |
---|
25 | { |
---|
26 | rtems_status_code status; |
---|
27 | rtems_interval ticks; |
---|
28 | |
---|
29 | if ( !ptms ) { |
---|
30 | errno = EFAULT; |
---|
31 | return -1; |
---|
32 | } |
---|
33 | |
---|
34 | /* "POSIX" does not seem to allow for not having a TOD */ |
---|
35 | status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks ); |
---|
36 | if ( status != RTEMS_SUCCESSFUL ) { |
---|
37 | assert( 0 ); |
---|
38 | return -1; |
---|
39 | } |
---|
40 | |
---|
41 | /* |
---|
42 | * RTEMS has no notion of system versus user time and although |
---|
43 | * a way to keep track of per task CPU usage was added since |
---|
44 | * 3.6.0, this routine does not utilize it yet. |
---|
45 | */ |
---|
46 | |
---|
47 | ptms->tms_utime = ticks; |
---|
48 | ptms->tms_stime = 0; |
---|
49 | ptms->tms_cutime = 0; |
---|
50 | ptms->tms_cstime = 0; |
---|
51 | |
---|
52 | return 0; |
---|
53 | } |
---|
54 | |
---|
55 | /* |
---|
56 | * times() |
---|
57 | * |
---|
58 | * times() system call wrapper for _times() above. |
---|
59 | */ |
---|
60 | |
---|
61 | clock_t times( |
---|
62 | struct tms *ptms |
---|
63 | ) |
---|
64 | { |
---|
65 | return _times( ptms ); |
---|
66 | } |
---|
67 | |
---|
68 | /* |
---|
69 | * _times_r |
---|
70 | * |
---|
71 | * This is the Newlib dependent reentrant version of times(). |
---|
72 | */ |
---|
73 | |
---|
74 | #if defined(RTEMS_NEWLIB) |
---|
75 | |
---|
76 | #include <reent.h> |
---|
77 | |
---|
78 | clock_t _times_r( |
---|
79 | struct _reent *ptr, |
---|
80 | struct tms *ptms |
---|
81 | ) |
---|
82 | { |
---|
83 | return _times( ptms ); |
---|
84 | } |
---|
85 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.