diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2014-01-25 00:07:31 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2014-01-25 00:07:31 +0000 |
commit | b7fe9575ab40a3bcde643a8ae8750ca6fd2aaad7 (patch) | |
tree | d220eddc3489f44845e9855e901290f7f712a626 /timer.c | |
parent | bea11309641a93ea51622fc85331d3960011afe4 (diff) | |
parent | d7ca0c3e555ef0b5250873ddce48ccf2326b017a (diff) | |
download | wavemon-b7fe9575ab40a3bcde643a8ae8750ca6fd2aaad7.tar.gz |
Merge tag 'upstream/0.7.6'
Upstream version 0.7.6
Diffstat (limited to 'timer.c')
-rw-r--r-- | timer.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -19,23 +19,23 @@ */ #include "wavemon.h" -void start_timer(struct timer *t, unsigned long duration) +static unsigned long get_usecs(void) { struct timeval tv; struct timezone tz; gettimeofday(&tv, &tz); - t->stime = tv.tv_sec * 1000000 + tv.tv_usec; - t->duration = duration; + return tv.tv_sec * 1000000 + tv.tv_usec; } -int end_timer(struct timer *t) +void start_timer(struct timer *t, unsigned long duration) { - struct timeval tv; - struct timezone tz; - - gettimeofday(&tv, &tz); + t->stime = get_usecs(); + t->duration = duration; +} - return (tv.tv_sec * 1000000 + tv.tv_usec >= t->stime + t->duration); +bool end_timer(struct timer *t) +{ + return get_usecs() >= t->stime + t->duration; } |