Constify count_syscall function
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 29 May 2014 18:10:00 +0000 (18:10 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 29 May 2014 18:10:00 +0000 (18:10 +0000)
* count.c (count_syscall): Add const qualifier to timeval argument and
rename it.  Store the wall clock time spent while in syscall in separate
timeval variable.
* defs.h (count_syscall): Update prototype.
* syscall.c (trace_syscall_exiting): Update count_syscall invocation.

count.c
defs.h
syscall.c

diff --git a/count.c b/count.c
index 83954661930411e9f4afde7dda47af209e25eb33..b0372a11ee7473d123d315b8aead089d463dc8f0 100644 (file)
--- a/count.c
+++ b/count.c
@@ -47,10 +47,11 @@ static struct call_counts *countv[SUPPORTED_PERSONALITIES];
 
 static struct timeval shortest = { 1000000, 0 };
 
-/* On entry, tv is syscall exit timestamp */
 void
-count_syscall(struct tcb *tcp, struct timeval *tv)
+count_syscall(struct tcb *tcp, const struct timeval *syscall_exiting_tv)
 {
+       struct timeval wtv;
+       struct timeval *tv = &wtv;
        struct call_counts *cc;
        unsigned long scno = tcp->scno;
 
@@ -69,7 +70,7 @@ count_syscall(struct tcb *tcp, struct timeval *tv)
                cc->errors++;
 
        /* tv = wall clock time spent while in syscall */
-       tv_sub(tv, tv, &tcp->etime);
+       tv_sub(tv, syscall_exiting_tv, &tcp->etime);
 
        /* Spent more wall clock time than spent system time? (usually yes) */
        if (tv_cmp(tv, &tcp->dtime) > 0) {
@@ -90,13 +91,13 @@ count_syscall(struct tcb *tcp, struct timeval *tv)
 
                if (tv_nz(&tcp->dtime))
                        /* tv = system time spent, if it isn't 0 */
-                       *tv = tcp->dtime;
+                       tv = &tcp->dtime;
                else if (tv_cmp(tv, &one_tick) > 0) {
                        /* tv = smallest "sane" time interval */
                        if (tv_cmp(&shortest, &one_tick) < 0)
-                               *tv = shortest;
+                               tv = &shortest;
                        else
-                               *tv = one_tick;
+                               tv = &one_tick;
                }
        }
        if (tv_cmp(tv, &shortest) < 0)
diff --git a/defs.h b/defs.h
index 22e847ba2ac4d6f5e853a4f2e511f135b1251dd3..002271ade27164d96b0453f80d3e1c8bc5ca332d 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -587,7 +587,7 @@ extern void set_overhead(int);
 extern void qualify(const char *);
 extern void print_pc(struct tcb *);
 extern int trace_syscall(struct tcb *);
-extern void count_syscall(struct tcb *, struct timeval *);
+extern void count_syscall(struct tcb *, const struct timeval *);
 extern void call_summary(FILE *);
 
 #if defined(AVR32) \
index 28bdb664611c819b1f9dc882116c4e266b0909fc..ca721abfa77038523215bf9f4e8fa0ba5cb3f68d 100644 (file)
--- a/syscall.c
+++ b/syscall.c
@@ -2523,8 +2523,7 @@ trace_syscall_exiting(struct tcb *tcp)
        }
 
        if (cflag) {
-               struct timeval t = tv;
-               count_syscall(tcp, &t);
+               count_syscall(tcp, &tv);
                if (cflag == CFLAG_ONLY_STATS) {
                        goto ret;
                }