diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2013-05-31 02:44:04 +0400 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2013-05-31 02:44:04 +0400 |
commit | 6d28d61df0d0afe87e1009065268e2fc35720b4b (patch) | |
tree | 40adeac854105a9dcf3da4031aa9708a796776a5 | |
parent | ac1f751fef135699aef0c3f46214fbc2f78be4d4 (diff) |
2013-05-30 Jeff Johnston <jjohnstn@redhat.com>
* 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.
-rw-r--r-- | libgloss/ChangeLog | 6 | ||||
-rw-r--r-- | libgloss/rs6000/Makefile.in | 2 | ||||
-rw-r--r-- | libgloss/rs6000/sim-times.c | 40 |
3 files changed, 47 insertions, 1 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 610dc7e89..b38d7cfa3 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,3 +1,9 @@ +2013-05-30 Jeff Johnston <jjohnstn@redhat.com> + + * 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. + 2013-05-14 DJ Delorie <dj@redhat.com> Nick Clifton <nickc@redhat.com> diff --git a/libgloss/rs6000/Makefile.in b/libgloss/rs6000/Makefile.in index 7471488ac..51714e59b 100644 --- a/libgloss/rs6000/Makefile.in +++ b/libgloss/rs6000/Makefile.in @@ -68,7 +68,7 @@ SIM_SCRIPTS = SIM_LDFLAGS = SIM_BSP = libsim.a SIM_CRT0 = sim-crt0.o -SIM_OBJS = sim-print.o sim-inbyte.o sim-sbrk.o sim-abort.o sim-errno.o simulator.o sim-getrusage.o +SIM_OBJS = sim-print.o sim-inbyte.o sim-sbrk.o sim-abort.o sim-errno.o simulator.o sim-getrusage.o sim-times.o SIM_TEST = sim-test SIM_INSTALL = install-sim 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 <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; +} |