diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-07-22 19:24:53 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-07-22 19:24:53 +0000 |
commit | e964bca8a89c2556bb4e152843e130da063f74f8 (patch) | |
tree | 19e9d9aabec3562a0b80cbdf757995f1d3fdedb2 /newlib/libc/machine/powerpc/time.c | |
parent | 5e7d0a5510c83685271168b990af0757e7daeefb (diff) | |
download | cygnal-e964bca8a89c2556bb4e152843e130da063f74f8.tar.gz cygnal-e964bca8a89c2556bb4e152843e130da063f74f8.tar.bz2 cygnal-e964bca8a89c2556bb4e152843e130da063f74f8.zip |
2002-07-19 Aldy Hernandez <aldyh@redhat.com>
* libc/machine/powerpc/time.c: New file.
* libc/machine/powerpc/Makefile.am (lib_a_SOURCES): Add
time.c.
* libc/machine/powerpc/Makefile.in: Regenerated.
Diffstat (limited to 'newlib/libc/machine/powerpc/time.c')
-rw-r--r-- | newlib/libc/machine/powerpc/time.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/newlib/libc/machine/powerpc/time.c b/newlib/libc/machine/powerpc/time.c new file mode 100644 index 000000000..64f4ddcb8 --- /dev/null +++ b/newlib/libc/machine/powerpc/time.c @@ -0,0 +1,36 @@ +/* Time support routines for PowerPC. + * + * Written by Aldy Hernandez. + */ + +#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; +} |