aboutsummaryrefslogtreecommitdiffstats
path: root/timer.c
diff options
context:
space:
mode:
authorJonathan McCrohan <jmccrohan@gmail.com>2014-01-25 00:07:30 +0000
committerJonathan McCrohan <jmccrohan@gmail.com>2014-01-25 00:07:30 +0000
commitd7ca0c3e555ef0b5250873ddce48ccf2326b017a (patch)
tree52fc801f0893eb7752524b2602d420afbda4ed59 /timer.c
parent3645c236e9720deb696e7aebc33cd9a6d8cbbdc6 (diff)
downloadwavemon-d7ca0c3e555ef0b5250873ddce48ccf2326b017a.tar.gz
Imported Upstream version 0.7.6upstream/0.7.6
Diffstat (limited to '')
-rw-r--r--timer.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/timer.c b/timer.c
index 5afcab4..cb6500c 100644
--- a/timer.c
+++ b/timer.c
@@ -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;
}