Commit b409186b8db0b11f6e5b0f014909df6fea81531f
1 parent
418a97af
added getrusage
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@178 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
33 additions
and
19 deletions
linux-user/syscall.c
... | ... | @@ -215,6 +215,29 @@ static inline void host_to_target_fds(target_long *target_fds, |
215 | 215 | #endif |
216 | 216 | } |
217 | 217 | |
218 | +static inline void host_to_target_rusage(struct target_rusage *target_rusage, | |
219 | + const struct rusage *rusage) | |
220 | +{ | |
221 | + target_rusage->ru_utime.tv_sec = tswapl(rusage->ru_utime.tv_sec); | |
222 | + target_rusage->ru_utime.tv_usec = tswapl(rusage->ru_utime.tv_usec); | |
223 | + target_rusage->ru_stime.tv_sec = tswapl(rusage->ru_stime.tv_sec); | |
224 | + target_rusage->ru_stime.tv_usec = tswapl(rusage->ru_stime.tv_usec); | |
225 | + target_rusage->ru_maxrss = tswapl(rusage->ru_maxrss); | |
226 | + target_rusage->ru_ixrss = tswapl(rusage->ru_ixrss); | |
227 | + target_rusage->ru_idrss = tswapl(rusage->ru_idrss); | |
228 | + target_rusage->ru_isrss = tswapl(rusage->ru_isrss); | |
229 | + target_rusage->ru_minflt = tswapl(rusage->ru_minflt); | |
230 | + target_rusage->ru_majflt = tswapl(rusage->ru_majflt); | |
231 | + target_rusage->ru_nswap = tswapl(rusage->ru_nswap); | |
232 | + target_rusage->ru_inblock = tswapl(rusage->ru_inblock); | |
233 | + target_rusage->ru_oublock = tswapl(rusage->ru_oublock); | |
234 | + target_rusage->ru_msgsnd = tswapl(rusage->ru_msgsnd); | |
235 | + target_rusage->ru_msgrcv = tswapl(rusage->ru_msgrcv); | |
236 | + target_rusage->ru_nsignals = tswapl(rusage->ru_nsignals); | |
237 | + target_rusage->ru_nvcsw = tswapl(rusage->ru_nvcsw); | |
238 | + target_rusage->ru_nivcsw = tswapl(rusage->ru_nivcsw); | |
239 | +} | |
240 | + | |
218 | 241 | static inline void target_to_host_timeval(struct timeval *tv, |
219 | 242 | const struct target_timeval *target_tv) |
220 | 243 | { |
... | ... | @@ -1636,7 +1659,15 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, |
1636 | 1659 | } |
1637 | 1660 | break; |
1638 | 1661 | case TARGET_NR_getrusage: |
1639 | - goto unimplemented; | |
1662 | + { | |
1663 | + struct rusage rusage; | |
1664 | + struct target_rusage *target_rusage = (void *)arg2; | |
1665 | + ret = get_errno(getrusage(arg1, &rusage)); | |
1666 | + if (!is_error(ret)) { | |
1667 | + host_to_target_rusage(target_rusage, &rusage); | |
1668 | + } | |
1669 | + } | |
1670 | + break; | |
1640 | 1671 | case TARGET_NR_gettimeofday: |
1641 | 1672 | { |
1642 | 1673 | 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, |
1886 | 1917 | if (status_ptr) |
1887 | 1918 | *status_ptr = tswap32(status); |
1888 | 1919 | if (target_rusage) { |
1889 | - target_rusage->ru_utime.tv_sec = tswapl(rusage.ru_utime.tv_sec); | |
1890 | - target_rusage->ru_utime.tv_usec = tswapl(rusage.ru_utime.tv_usec); | |
1891 | - target_rusage->ru_stime.tv_sec = tswapl(rusage.ru_stime.tv_sec); | |
1892 | - target_rusage->ru_stime.tv_usec = tswapl(rusage.ru_stime.tv_usec); | |
1893 | - target_rusage->ru_maxrss = tswapl(rusage.ru_maxrss); | |
1894 | - target_rusage->ru_ixrss = tswapl(rusage.ru_ixrss); | |
1895 | - target_rusage->ru_idrss = tswapl(rusage.ru_idrss); | |
1896 | - target_rusage->ru_isrss = tswapl(rusage.ru_isrss); | |
1897 | - target_rusage->ru_minflt = tswapl(rusage.ru_minflt); | |
1898 | - target_rusage->ru_majflt = tswapl(rusage.ru_majflt); | |
1899 | - target_rusage->ru_nswap = tswapl(rusage.ru_nswap); | |
1900 | - target_rusage->ru_inblock = tswapl(rusage.ru_inblock); | |
1901 | - target_rusage->ru_oublock = tswapl(rusage.ru_oublock); | |
1902 | - target_rusage->ru_msgsnd = tswapl(rusage.ru_msgsnd); | |
1903 | - target_rusage->ru_msgrcv = tswapl(rusage.ru_msgrcv); | |
1904 | - target_rusage->ru_nsignals = tswapl(rusage.ru_nsignals); | |
1905 | - target_rusage->ru_nvcsw = tswapl(rusage.ru_nvcsw); | |
1906 | - target_rusage->ru_nivcsw = tswapl(rusage.ru_nivcsw); | |
1920 | + host_to_target_rusage(target_rusage, &rusage); | |
1907 | 1921 | } |
1908 | 1922 | } |
1909 | 1923 | } | ... | ... |