Commit c596ed17139b50a45a75a5491797d3b920385566

Authored by bellard
1 parent 91cf4d88

times() fix


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@327 c046a42c-6fe2-441c-8c8c-71466251a162
linux-user/syscall.c
@@ -210,6 +210,21 @@ static inline void host_to_target_fds(target_long *target_fds, @@ -210,6 +210,21 @@ static inline void host_to_target_fds(target_long *target_fds,
210 #endif 210 #endif
211 } 211 }
212 212
  213 +#if defined(__alpha__)
  214 +#define HOST_HZ 1024
  215 +#else
  216 +#define HOST_HZ 100
  217 +#endif
  218 +
  219 +static inline long host_to_target_clock_t(long ticks)
  220 +{
  221 +#if HOST_HZ == TARGET_HZ
  222 + return ticks;
  223 +#else
  224 + return ((int64_t)ticks * TARGET_HZ) / HOST_HZ;
  225 +#endif
  226 +}
  227 +
213 static inline void host_to_target_rusage(struct target_rusage *target_rusage, 228 static inline void host_to_target_rusage(struct target_rusage *target_rusage,
214 const struct rusage *rusage) 229 const struct rusage *rusage)
215 { 230 {
@@ -1423,11 +1438,13 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, @@ -1423,11 +1438,13 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3,
1423 struct tms tms; 1438 struct tms tms;
1424 ret = get_errno(times(&tms)); 1439 ret = get_errno(times(&tms));
1425 if (tmsp) { 1440 if (tmsp) {
1426 - tmsp->tms_utime = tswapl(tms.tms_utime);  
1427 - tmsp->tms_stime = tswapl(tms.tms_stime);  
1428 - tmsp->tms_cutime = tswapl(tms.tms_cutime);  
1429 - tmsp->tms_cstime = tswapl(tms.tms_cstime); 1441 + tmsp->tms_utime = tswapl(host_to_target_clock_t(tms.tms_utime));
  1442 + tmsp->tms_stime = tswapl(host_to_target_clock_t(tms.tms_stime));
  1443 + tmsp->tms_cutime = tswapl(host_to_target_clock_t(tms.tms_cutime));
  1444 + tmsp->tms_cstime = tswapl(host_to_target_clock_t(tms.tms_cstime));
1430 } 1445 }
  1446 + if (!is_error(ret))
  1447 + ret = host_to_target_clock_t(ret);
1431 } 1448 }
1432 break; 1449 break;
1433 case TARGET_NR_prof: 1450 case TARGET_NR_prof:
linux-user/syscall_defs.h
@@ -383,6 +383,8 @@ struct target_itimerval { @@ -383,6 +383,8 @@ struct target_itimerval {
383 383
384 typedef target_long target_clock_t; 384 typedef target_long target_clock_t;
385 385
  386 +#define TARGET_HZ 100
  387 +
386 struct target_tms { 388 struct target_tms {
387 target_clock_t tms_utime; 389 target_clock_t tms_utime;
388 target_clock_t tms_stime; 390 target_clock_t tms_stime;
@@ -539,8 +541,8 @@ static inline void target_siginitset(target_sigset_t *d, target_ulong set) @@ -539,8 +541,8 @@ static inline void target_siginitset(target_sigset_t *d, target_ulong set)
539 d->sig[i] = 0; 541 d->sig[i] = 0;
540 } 542 }
541 543
542 -void host_to_target_sigset(target_sigset_t *d, sigset_t *s);  
543 -void target_to_host_sigset(sigset_t *d, target_sigset_t *s); 544 +void host_to_target_sigset(target_sigset_t *d, const sigset_t *s);
  545 +void target_to_host_sigset(sigset_t *d, const target_sigset_t *s);
544 void host_to_target_old_sigset(target_ulong *old_sigset, 546 void host_to_target_old_sigset(target_ulong *old_sigset,
545 const sigset_t *sigset); 547 const sigset_t *sigset);
546 void target_to_host_old_sigset(sigset_t *sigset, 548 void target_to_host_old_sigset(sigset_t *sigset,
@@ -590,6 +592,8 @@ int do_sigaction(int sig, const struct target_sigaction *act, @@ -590,6 +592,8 @@ int do_sigaction(int sig, const struct target_sigaction *act,
590 #define TARGET_SIGPROF 27 592 #define TARGET_SIGPROF 27
591 #define TARGET_SIGWINCH 28 593 #define TARGET_SIGWINCH 28
592 #define TARGET_SIGIO 29 594 #define TARGET_SIGIO 29
  595 +#define TARGET_SIGPWR 30
  596 +#define TARGET_SIGSYS 31
593 #define TARGET_SIGRTMIN 32 597 #define TARGET_SIGRTMIN 32
594 598
595 #define TARGET_SIG_BLOCK 0 /* for blocking signals */ 599 #define TARGET_SIG_BLOCK 0 /* for blocking signals */