]> granicus.if.org Git - strace/commitdiff
2003-11-01 Roland McGrath <roland@redhat.com>
authorRoland McGrath <roland@redhat.com>
Sat, 1 Nov 2003 22:11:22 +0000 (22:11 +0000)
committerRoland McGrath <roland@redhat.com>
Sat, 1 Nov 2003 22:11:22 +0000 (22:11 +0000)
* syscall.c (trace_syscall) [LINUX]: Calculate ONE_TICK once using
setitimer rather than hard-coding a value based on HZ.

syscall.c

index 1fb30d9cd3509b3c86ec9cae47346032ff55d0e7..d4f6413ae4b0038098954b549be23b789deebfef 100644 (file)
--- 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;