source: rtems/c/src/exec/libcsupport/src/__times.c @ b43314a

4.104.114.84.95
Last change on this file since b43314a was b43314a, checked in by Joel Sherrill <joel.sherrill@…>, on Jun 28, 2002 at 6:51:35 PM

2002-06-28 Joel Sherrill <joel@…>

  • src/times.c: Cleaned up comments, return more information, and eliminated the fatal error on clock not set since it cannot occur.
  • Property mode set to 100644
File size: 1.4 KB
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#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
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
26clock_t _times(
27   struct tms  *ptms
28)
29{
30  rtems_status_code  status;
31  rtems_interval     ticks;
32
33  if ( !ptms ) {
34    errno = EFAULT;
35    return -1;
36  }
37
38  /*
39   *  RTEMS technically has no notion of system versus user time
40   *  since there is no separation of OS from application tasks.
41   *  But we can at least make a distinction between the number
42   *  of ticks since boot and the number of ticks executed by this
43   *  this thread.
44   */
45
46  ptms->tms_utime  = _Thread_Executing->ticks_executed;
47  ptms->tms_stime  = ticks;
48  ptms->tms_cutime = 0;
49  ptms->tms_cstime = 0;
50
51  return ticks;
52}
53
54/*
55 *  times()
56 *
57 *  times() system call wrapper for _times() above.
58 */
59
60clock_t times(
61   struct tms  *ptms
62)
63{
64  return _times( ptms );
65}
66
67/*
68 *  _times_r
69 *
70 *  This is the Newlib dependent reentrant version of times().
71 */
72
73#if defined(RTEMS_NEWLIB)
74
75#include <reent.h>
76
77clock_t _times_r(
78   struct _reent *ptr,
79   struct tms  *ptms
80)
81{
82  return _times( ptms );
83}
84#endif
Note: See TracBrowser for help on using the repository browser.