source: rtems/cpukit/libcsupport/src/getrusage.c @ 79d145a7

5
Last change on this file since 79d145a7 was 79d145a7, checked in by Sebastian Huber <sebastian.huber@…>, on Oct 18, 2018 at 12:36:44 PM

Remove optional getrusage() declaration

Declaration provided by Newlib since 2014.

Update #3409.

  • 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
20int getrusage(int who, struct rusage *usage)
21{
22  struct timespec uptime;
23  struct timeval  rtime;
24
25  if ( !usage )
26    rtems_set_errno_and_return_minus_one( EFAULT );
27
28  /*
29   *  RTEMS only has a single process so there are no children.
30   *  The single process has been running since the system
31   *  was booted and since there is no distinction between system
32   *  and user time, we will just report the uptime.
33   */
34  if (who == RUSAGE_SELF) {
35    rtems_clock_get_uptime( &uptime );
36
37    rtime.tv_sec  = uptime.tv_sec;
38    rtime.tv_usec = uptime.tv_nsec / 1000;
39
40    usage->ru_utime = rtime;
41    usage->ru_stime = rtime;
42
43    return 0;
44  }
45
46  if (who == RUSAGE_CHILDREN) {
47    rtems_set_errno_and_return_minus_one( ENOSYS );
48  }
49
50  rtems_set_errno_and_return_minus_one( EINVAL );
51}
52
Note: See TracBrowser for help on using the repository browser.