summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-07-13 17:32:31 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-07-13 17:32:31 +0000
commitc596ed17139b50a45a75a5491797d3b920385566 (patch)
tree4ff07a4cbb97f048407bc943b4069cad97ec0ad7
parent91cf4d88fbb174ba5a4ade9c4479f3b0775a5599 (diff)
downloadqemu-c596ed17139b50a45a75a5491797d3b920385566.tar.gz
times() fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@327 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--linux-user/syscall.c25
-rw-r--r--linux-user/syscall_defs.h8
2 files changed, 27 insertions, 6 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 932fe4658d..1204a62c43 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -210,6 +210,21 @@ static inline void host_to_target_fds(target_long *target_fds,
#endif
}
+#if defined(__alpha__)
+#define HOST_HZ 1024
+#else
+#define HOST_HZ 100
+#endif
+
+static inline long host_to_target_clock_t(long ticks)
+{
+#if HOST_HZ == TARGET_HZ
+ return ticks;
+#else
+ return ((int64_t)ticks * TARGET_HZ) / HOST_HZ;
+#endif
+}
+
static inline void host_to_target_rusage(struct target_rusage *target_rusage,
const struct rusage *rusage)
{
@@ -1423,11 +1438,13 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
struct tms tms;
ret = get_errno(times(&tms));
if (tmsp) {
- tmsp->tms_utime = tswapl(tms.tms_utime);
- tmsp->tms_stime = tswapl(tms.tms_stime);
- tmsp->tms_cutime = tswapl(tms.tms_cutime);
- tmsp->tms_cstime = tswapl(tms.tms_cstime);
+ tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime));
+ tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime));
+ tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime));
+ tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime));
}
+ if (!is_error(ret))
+ ret = host_to_target_clock_t(ret);
}
break;
case TARGET_NR_prof:
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 5caf2d855e..a4613bdf70 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -383,6 +383,8 @@ struct target_itimerval {
typedef target_long target_clock_t;
+#define TARGET_HZ 100
+
struct target_tms {
target_clock_t tms_utime;
target_clock_t tms_stime;
@@ -539,8 +541,8 @@ static inline void target_siginitset(target_sigset_t *d, target_ulong set)
d->sig[i] = 0;
}
-void host_to_target_sigset(target_sigset_t *d, sigset_t *s);
-void target_to_host_sigset(sigset_t *d, target_sigset_t *s);
+void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
+void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
void host_to_target_old_sigset(target_ulong *old_sigset,
const sigset_t *sigset);
void target_to_host_old_sigset(sigset_t *sigset,
@@ -590,6 +592,8 @@ int do_sigaction(int sig, const struct target_sigaction *act,
#define TARGET_SIGPROF 27
#define TARGET_SIGWINCH 28
#define TARGET_SIGIO 29
+#define TARGET_SIGPWR 30
+#define TARGET_SIGSYS 31
#define TARGET_SIGRTMIN 32
#define TARGET_SIG_BLOCK 0 /* for blocking signals */