Welcome to mirror list, hosted at ThFree Co, Russian Federation.

sim-times.c « rs6000 « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 171ab158931154b254d783d01b7fd1222d6a5a4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* sim-times.c - times support routines for PowerPC.
 *
 * Written by Aldy Hernandez.
 *
 * This file is licensed with the default Red Hat license
 * found in COPYING.NEWLIB.
 * http://sourceware.org/cgi-bin/cvsweb.cgi/src/COPYING.NEWLIB?rev=1.32&content-type=text/x-cvsweb-markup&cvsroot=src
 */

#include <_ansi.h>
#include <reent.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/resource.h>

clock_t
times (struct tms *tp)
{
  struct rusage usage;
  union {
    struct rusage r;
    /* Newlib's rusage has only 2 fields.  We need to make room for
       when we call the system's rusage.  This should be enough.  */
    int filler[32];
  } host_ru;

  getrusage (RUSAGE_SELF, (void *)&host_ru);

  if (tp)
    {
      tp->tms_utime = host_ru.r.ru_utime.tv_sec * 1000
	+ host_ru.r.ru_utime.tv_usec;
      tp->tms_stime = host_ru.r.ru_stime.tv_sec * 1000
	+ host_ru.r.ru_stime.tv_usec;
      tp->tms_cutime = 0;	/* user time, children */
      tp->tms_cstime = 0;	/* system time, children */
    }

  return tp->tms_utime;
}