Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2013-01-06 06:04:04 +0400
committerFelix Fietkau <nbd@openwrt.org>2013-01-06 06:04:04 +0400
commitdde64e47cadbd245a99f145869eb400b68cc82e9 (patch)
tree25e4448a9b61627e130d43c5ba96fedd51525474 /uloop.c
parentaa4f3bde06ea1410f1835590ae025e044f2364fb (diff)
uloop: use clock_gettime with the monotonic clock instead of using gettimeofday()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Diffstat (limited to 'uloop.c')
-rw-r--r--uloop.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/uloop.c b/uloop.c
index ecf26ec..2de4feb 100644
--- a/uloop.c
+++ b/uloop.c
@@ -351,6 +351,15 @@ int uloop_timeout_add(struct uloop_timeout *timeout)
return 0;
}
+static void uloop_gettime(struct timeval *tv)
+{
+ struct timespec ts;
+
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+ tv->tv_sec = ts.tv_sec;
+ tv->tv_usec = ts.tv_nsec / 1000;
+}
+
int uloop_timeout_set(struct uloop_timeout *timeout, int msecs)
{
struct timeval *time = &timeout->time;
@@ -358,7 +367,7 @@ int uloop_timeout_set(struct uloop_timeout *timeout, int msecs)
if (timeout->pending)
uloop_timeout_cancel(timeout);
- gettimeofday(&timeout->time, NULL);
+ uloop_gettime(&timeout->time);
time->tv_sec += msecs / 1000;
time->tv_usec += (msecs % 1000) * 1000;
@@ -521,7 +530,7 @@ void uloop_run(void)
uloop_setup_signals();
while(!uloop_cancelled)
{
- gettimeofday(&tv, NULL);
+ uloop_gettime(&tv);
uloop_process_timeouts(&tv);
if (uloop_cancelled)
break;