source: rtems/cpukit/libcsupport/src/__times.c @ da154e14

4.115
Last change on this file since da154e14 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 2.2 KB
Line 
1/*
2 *  times() - POSIX 1003.1b 4.5.2 - Get Process Times
3 *
4 *  COPYRIGHT (c) 1989-2010.
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.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems.h>
17
18#include <sys/times.h>
19#include <time.h>
20#include <sys/time.h>
21#include <errno.h>
22#include <rtems/seterr.h>
23#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
24  #include <rtems/score/timestamp.h>
25#endif
26
27clock_t _times(
28   struct tms  *ptms
29)
30{
31  rtems_interval ticks;
32
33  if ( !ptms )
34    rtems_set_errno_and_return_minus_one( EFAULT );
35
36  /*
37   *  This call does not depend on TOD being initialized and can't fail.
38   */
39
40  ticks = rtems_clock_get_ticks_since_boot();
41
42  /*
43   *  RTEMS technically has no notion of system versus user time
44   *  since there is no separation of OS from application tasks.
45   *  But we can at least make a distinction between the number
46   *  of ticks since boot and the number of ticks executed by this
47   *  this thread.
48   */
49
50  #ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
51    {
52      Timestamp_Control per_tick;
53      uint32_t          ticks;
54      uint32_t          fractional_ticks;
55
56      _Timestamp_Set(
57        &per_tick,
58        rtems_configuration_get_microseconds_per_tick() /
59            TOD_MICROSECONDS_PER_SECOND,
60        (rtems_configuration_get_nanoseconds_per_tick() %
61            TOD_NANOSECONDS_PER_SECOND)
62      );
63
64      _Timestamp_Divide(
65        &_Thread_Executing->cpu_time_used,
66        &per_tick,
67        &ticks,
68        &fractional_ticks
69      );
70      ptms->tms_utime = ticks;
71    }
72  #else
73    ptms->tms_utime  = _Thread_Executing->cpu_time_used;
74  #endif
75  ptms->tms_stime  = ticks;
76  ptms->tms_cutime = 0;
77  ptms->tms_cstime = 0;
78
79  return ticks;
80}
81
82/*
83 *  times()
84 *
85 *  times() system call wrapper for _times() above.
86 */
87
88clock_t times(
89   struct tms  *ptms
90)
91{
92  return _times( ptms );
93}
94
95/*
96 *  _times_r
97 *
98 *  This is the Newlib dependent reentrant version of times().
99 */
100
101#if defined(RTEMS_NEWLIB)
102
103#include <reent.h>
104
105clock_t _times_r(
106   struct _reent *ptr __attribute__((unused)),
107   struct tms  *ptms
108)
109{
110  return _times( ptms );
111}
112#endif
Note: See TracBrowser for help on using the repository browser.