4.115
Last change
on this file since e02d5dd9 was
c499856,
checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47
|
Change all references of rtems.com to rtems.org.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.org/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #if HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <sys/resource.h> |
---|
15 | #include <errno.h> |
---|
16 | |
---|
17 | #include <rtems.h> |
---|
18 | #include <rtems/seterr.h> |
---|
19 | |
---|
20 | #if !HAVE_DECL_GETRUSAGE |
---|
21 | extern int getrusage(int who, struct rusage *usage); |
---|
22 | #endif |
---|
23 | |
---|
24 | int getrusage(int who, struct rusage *usage) |
---|
25 | { |
---|
26 | struct timespec uptime; |
---|
27 | struct timeval rtime; |
---|
28 | |
---|
29 | if ( !usage ) |
---|
30 | rtems_set_errno_and_return_minus_one( EFAULT ); |
---|
31 | |
---|
32 | /* |
---|
33 | * RTEMS only has a single process so there are no children. |
---|
34 | * The single process has been running since the system |
---|
35 | * was booted and since there is no distinction between system |
---|
36 | * and user time, we will just report the uptime. |
---|
37 | */ |
---|
38 | if (who == RUSAGE_SELF) { |
---|
39 | rtems_clock_get_uptime( &uptime ); |
---|
40 | |
---|
41 | rtime.tv_sec = uptime.tv_sec; |
---|
42 | rtime.tv_usec = uptime.tv_nsec / 1000; |
---|
43 | |
---|
44 | usage->ru_utime = rtime; |
---|
45 | usage->ru_stime = rtime; |
---|
46 | |
---|
47 | return 0; |
---|
48 | } |
---|
49 | |
---|
50 | if (who == RUSAGE_CHILDREN) { |
---|
51 | rtems_set_errno_and_return_minus_one( ENOSYS ); |
---|
52 | } |
---|
53 | |
---|
54 | rtems_set_errno_and_return_minus_one( EINVAL ); |
---|
55 | } |
---|
56 | |
---|
Note: See
TracBrowser
for help on using the repository browser.