From 6d28d61df0d0afe87e1009065268e2fc35720b4b Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Thu, 30 May 2013 22:44:04 +0000 Subject: 2013-05-30 Jeff Johnston * rs6000/Makefile.in: Add sim-times support. This file has been moved from newlib/libc/machine/powerpc and renamed. * rs6000/sim-times.c: New file. --- libgloss/rs6000/sim-times.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 libgloss/rs6000/sim-times.c (limited to 'libgloss/rs6000/sim-times.c') diff --git a/libgloss/rs6000/sim-times.c b/libgloss/rs6000/sim-times.c new file mode 100644 index 000000000..171ab1589 --- /dev/null +++ b/libgloss/rs6000/sim-times.c @@ -0,0 +1,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 +#include +#include +#include + +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; +} -- cgit v1.2.3