From: Roland McGrath Date: Sat, 1 Nov 2003 22:11:22 +0000 (+0000) Subject: 2003-11-01 Roland McGrath X-Git-Tag: v4.5.18~683 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee9c5b5d6321bc7e9c7d0553716d9d4fe09f1061;p=strace 2003-11-01 Roland McGrath * syscall.c (trace_syscall) [LINUX]: Calculate ONE_TICK once using setitimer rather than hard-coding a value based on HZ. --- diff --git a/syscall.c b/syscall.c index 1fb30d9c..d4f6413a 100644 --- a/syscall.c +++ b/syscall.c @@ -2135,8 +2135,16 @@ struct tcb *tcp; tv_sub(&tv, &tv, &tcp->etime); #ifdef LINUX if (tv_cmp(&tv, &tcp->dtime) > 0) { - static struct timeval one_tick = - { 0, 1000000 / HZ }; + static struct timeval one_tick; + if (one_tick.tv_usec == 0) { + /* Initialize it. */ + struct itimerval it; + memset(&it, 0, sizeof it); + it.it_interval.tv_usec = 1; + setitimer(ITIMER_REAL, &it, NULL); + getitimer(ITIMER_REAL, &it); + one_tick = it.it_interval; + } if (tv_nz(&tcp->dtime)) tv = tcp->dtime;