summaryrefslogtreecommitdiff
path: root/sys/compat/linux32
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2008-09-08 11:29:42 +0000
committerchristos <christos@NetBSD.org>2008-09-08 11:29:42 +0000
commitae6357afe4af445e971c2dccca2e28b41f4a9ac3 (patch)
tree8c57f1584e084cea83b6922c3544259536dbf710 /sys/compat/linux32
parent80399094f9ed2349182137437adaa40b88ed2b55 (diff)
fix broken linux32_sys_times, copied from linux_sys_times.
Diffstat (limited to 'sys/compat/linux32')
-rw-r--r--sys/compat/linux32/common/linux32_time.c45
1 files changed, 25 insertions, 20 deletions
diff --git a/sys/compat/linux32/common/linux32_time.c b/sys/compat/linux32/common/linux32_time.c
index 94e52ad5466..1ac81810091 100644
--- a/sys/compat/linux32/common/linux32_time.c
+++ b/sys/compat/linux32/common/linux32_time.c
@@ -1,4 +1,4 @@
-/* $NetBSD: linux32_time.c,v 1.19 2008/04/24 18:39:23 ad Exp $ */
+/* $NetBSD: linux32_time.c,v 1.20 2008/09/08 11:29:42 christos Exp $ */
/*-
* Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved.
@@ -33,7 +33,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.19 2008/04/24 18:39:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.20 2008/09/08 11:29:42 christos Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -156,37 +156,42 @@ timeval_to_clock_t(struct timeval *tv)
return tv->tv_sec * hz + tv->tv_usec / (1000000 / hz);
}
+#define CONVTCK(r) (r.tv_sec * hz + r.tv_usec / (1000000 / hz))
+
int
linux32_sys_times(struct lwp *l, const struct linux32_sys_times_args *uap, register_t *retval)
{
/* {
syscallarg(linux32_tmsp_t) tms;
} */
- struct linux32_tms ltms32;
-
- struct timeval t;
- struct rusage ru;
- struct proc *p = l->l_proc;
+ struct proc *p = l->l_proc;
+ struct timeval t;
+ int error;
- mutex_enter(p->p_lock);
- ru = p->p_stats->p_ru;
- calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL);
- rulwps(p, &ru);
- mutex_exit(p->p_lock);
+ if (SCARG_P32(uap, tms)) {
+ struct linux32_tms ltms32;
+ struct rusage ru;
- ltms32.ltms32_utime = timeval_to_clock_t(&ru.ru_utime);
- ltms32.ltms32_stime = timeval_to_clock_t(&ru.ru_stime);
+ mutex_enter(p->p_lock);
+ calcru(p, &ru.ru_utime, &ru.ru_stime, NULL, NULL);
+ ltms32.ltms32_utime = CONVTCK(ru.ru_utime);
+ ltms32.ltms32_stime = CONVTCK(ru.ru_stime);
+ ltms32.ltms32_cutime = CONVTCK(p->p_stats->p_cru.ru_utime);
+ ltms32.ltms32_cstime = CONVTCK(p->p_stats->p_cru.ru_stime);
+ mutex_exit(p->p_lock);
- ru = p->p_stats->p_cru;
- ltms32.ltms32_cutime = timeval_to_clock_t(&ru.ru_utime);
- ltms32.ltms32_cstime = timeval_to_clock_t(&ru.ru_stime);
+ if ((error = copyout(&ltms32, SCARG(uap, tms), sizeof ltms32)))
+ return error;
+ }
- microtime(&t);
- *retval = timeval_to_clock_t(&t);
+ getmicrouptime(&t);
- return copyout(&ltms32, SCARG_P32(uap, tms), sizeof(ltms32));
+ retval[0] = ((linux32_clock_t)(CONVTCK(t)));
+ return 0;
}
+#undef CONVTCK
+
int
linux32_sys_stime(struct lwp *l, const struct linux32_sys_stime_args *uap, register_t *retval)
{