source:
rtems/c/src/exec/libcsupport/src/__times.c
@
9c49db4
Last change on this file since 9c49db4 was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44 | |
---|---|
|
|
File size: 1.5 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 | /* "POSIX" does not seem to allow for not having a TOD */ | |
[07a3253d] | 39 | status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks ); |
[ac7d5ef0] | 40 | if ( status != RTEMS_SUCCESSFUL ) { |
41 | assert( 0 ); | |
42 | return -1; | |
43 | } | |
44 | ||
45 | /* | |
[07a3253d] | 46 | * RTEMS has no notion of system versus user time and although |
47 | * a way to keep track of per task CPU usage was added since | |
48 | * 3.6.0, this routine does not utilize it yet. | |
[ac7d5ef0] | 49 | */ |
50 | ||
[07a3253d] | 51 | ptms->tms_utime = ticks; |
[ac7d5ef0] | 52 | ptms->tms_stime = 0; |
53 | ptms->tms_cutime = 0; | |
54 | ptms->tms_cstime = 0; | |
55 | ||
56 | return 0; | |
57 | } | |
58 | ||
[07a3253d] | 59 | /* |
60 | * times() | |
61 | * | |
62 | * times() system call wrapper for _times() above. | |
63 | */ | |
64 | ||
[ac7d5ef0] | 65 | clock_t times( |
66 | struct tms *ptms | |
67 | ) | |
68 | { | |
69 | return _times( ptms ); | |
70 | } | |
71 | ||
[07a3253d] | 72 | /* |
73 | * _times_r | |
74 | * | |
75 | * This is the Newlib dependent reentrant version of times(). | |
76 | */ | |
77 | ||
[421dfef6] | 78 | #if defined(RTEMS_NEWLIB) |
[07a3253d] | 79 | |
80 | #include <reent.h> | |
81 | ||
[3294650] | 82 | clock_t _times_r( |
83 | struct _reent *ptr, | |
84 | struct tms *ptms | |
85 | ) | |
86 | { | |
[07a3253d] | 87 | return _times( ptms ); |
[3294650] | 88 | } |
[421dfef6] | 89 | #endif |
Note: See TracBrowser
for help on using the repository browser.