source: rtems/c/src/exec/libcsupport/src/__times.c @ 9c49db4

4.104.114.84.95
Last change on this file since 9c49db4 was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 8, 2001 at 6:26:44 PM

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.5 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  /* "POSIX" does not seem to allow for not having a TOD */
39  status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks );
40  if ( status != RTEMS_SUCCESSFUL ) {
41    assert( 0 );
42    return -1;
43  }
44
45  /*
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.
49   */
50
51  ptms->tms_utime  = ticks;
52  ptms->tms_stime  = 0;
53  ptms->tms_cutime = 0;
54  ptms->tms_cstime = 0;
55
56  return 0;
57}
58
59/*
60 *  times()
61 *
62 *  times() system call wrapper for _times() above.
63 */
64
65clock_t times(
66   struct tms  *ptms
67)
68{
69  return _times( ptms );
70}
71
72/*
73 *  _times_r
74 *
75 *  This is the Newlib dependent reentrant version of times().
76 */
77
78#if defined(RTEMS_NEWLIB)
79
80#include <reent.h>
81
82clock_t _times_r(
83   struct _reent *ptr,
84   struct tms  *ptms
85)
86{
87  return _times( ptms );
88}
89#endif
Note: See TracBrowser for help on using the repository browser.