aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-05-16 15:39:34 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-05-16 15:39:34 +0000
commitb409186b8db0b11f6e5b0f014909df6fea81531f (patch)
tree6c96507a2ada73db9bf5675df25000437b69c881
parent418a97afa1017a49b60dae3abb9c46d8dde1f8df (diff)
added getrusage
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@178 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--linux-user/syscall.c52
1 files changed, 33 insertions, 19 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b0a4652f07..90fb9dcd3c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -215,6 +215,29 @@ static inline void host_to_target_fds(target_long *target_fds,
#endif
}
+static inline void host_to_target_rusage(struct target_rusage *target_rusage,
+ const struct rusage *rusage)
+{
+ target_rusage->ru_utime.tv_sec = tswapl(rusage->ru_utime.tv_sec);
+ target_rusage->ru_utime.tv_usec = tswapl(rusage->ru_utime.tv_usec);
+ target_rusage->ru_stime.tv_sec = tswapl(rusage->ru_stime.tv_sec);
+ target_rusage->ru_stime.tv_usec = tswapl(rusage->ru_stime.tv_usec);
+ target_rusage->ru_maxrss = tswapl(rusage->ru_maxrss);
+ target_rusage->ru_ixrss = tswapl(rusage->ru_ixrss);
+ target_rusage->ru_idrss = tswapl(rusage->ru_idrss);
+ target_rusage->ru_isrss = tswapl(rusage->ru_isrss);
+ target_rusage->ru_minflt = tswapl(rusage->ru_minflt);
+ target_rusage->ru_majflt = tswapl(rusage->ru_majflt);
+ target_rusage->ru_nswap = tswapl(rusage->ru_nswap);
+ target_rusage->ru_inblock = tswapl(rusage->ru_inblock);
+ target_rusage->ru_oublock = tswapl(rusage->ru_oublock);
+ target_rusage->ru_msgsnd = tswapl(rusage->ru_msgsnd);
+ target_rusage->ru_msgrcv = tswapl(rusage->ru_msgrcv);
+ target_rusage->ru_nsignals = tswapl(rusage->ru_nsignals);
+ target_rusage->ru_nvcsw = tswapl(rusage->ru_nvcsw);
+ target_rusage->ru_nivcsw = tswapl(rusage->ru_nivcsw);
+}
+
static inline void target_to_host_timeval(struct timeval *tv,
const struct target_timeval *target_tv)
{
@@ -1636,7 +1659,15 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
}
break;
case TARGET_NR_getrusage:
- goto unimplemented;
+ {
+ struct rusage rusage;
+ struct target_rusage *target_rusage = (void *)arg2;
+ ret = get_errno(getrusage(arg1, &rusage));
+ if (!is_error(ret)) {
+ host_to_target_rusage(target_rusage, &rusage);
+ }
+ }
+ break;
case TARGET_NR_gettimeofday:
{
struct target_timeval *target_tv = (void *)arg1;
@@ -1886,24 +1917,7 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
if (status_ptr)
*status_ptr = tswap32(status);
if (target_rusage) {
- target_rusage->ru_utime.tv_sec = tswapl(rusage.ru_utime.tv_sec);
- target_rusage->ru_utime.tv_usec = tswapl(rusage.ru_utime.tv_usec);
- target_rusage->ru_stime.tv_sec = tswapl(rusage.ru_stime.tv_sec);
- target_rusage->ru_stime.tv_usec = tswapl(rusage.ru_stime.tv_usec);
- target_rusage->ru_maxrss = tswapl(rusage.ru_maxrss);
- target_rusage->ru_ixrss = tswapl(rusage.ru_ixrss);
- target_rusage->ru_idrss = tswapl(rusage.ru_idrss);
- target_rusage->ru_isrss = tswapl(rusage.ru_isrss);
- target_rusage->ru_minflt = tswapl(rusage.ru_minflt);
- target_rusage->ru_majflt = tswapl(rusage.ru_majflt);
- target_rusage->ru_nswap = tswapl(rusage.ru_nswap);
- target_rusage->ru_inblock = tswapl(rusage.ru_inblock);
- target_rusage->ru_oublock = tswapl(rusage.ru_oublock);
- target_rusage->ru_msgsnd = tswapl(rusage.ru_msgsnd);
- target_rusage->ru_msgrcv = tswapl(rusage.ru_msgrcv);
- target_rusage->ru_nsignals = tswapl(rusage.ru_nsignals);
- target_rusage->ru_nvcsw = tswapl(rusage.ru_nvcsw);
- target_rusage->ru_nivcsw = tswapl(rusage.ru_nivcsw);
+ host_to_target_rusage(target_rusage, &rusage);
}
}
}