From: Stijn Tintel Date: Thu, 4 Nov 2021 10:26:41 +0000 (+0200) Subject: uloop: add uloop_timeout_remaining64 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3344157381505e343b334e2eb6c60c9d3318e5bb;p=project%2Flibubox.git uloop: add uloop_timeout_remaining64 This uses the same return type as tv_diff so we don't need to check for integer overflow. Signed-off-by: Stijn Tintel Acked-by: Jo-Philipp Wich Acked-by: John Crispin --- diff --git a/uloop.c b/uloop.c index 769b6c5..0134fa4 100644 --- a/uloop.c +++ b/uloop.c @@ -338,6 +338,18 @@ int uloop_timeout_remaining(struct uloop_timeout *timeout) return (int)td; } +int64_t uloop_timeout_remaining64(struct uloop_timeout *timeout) +{ + struct timeval now; + + if (!timeout->pending) + return -1; + + uloop_gettime(&now); + + return tv_diff(&timeout->time, &now); +} + int uloop_process_add(struct uloop_process *p) { struct uloop_process *tmp; diff --git a/uloop.h b/uloop.h index 36084f5..7ac345e 100644 --- a/uloop.h +++ b/uloop.h @@ -93,6 +93,7 @@ int uloop_timeout_add(struct uloop_timeout *timeout); int uloop_timeout_set(struct uloop_timeout *timeout, int msecs); int uloop_timeout_cancel(struct uloop_timeout *timeout); int uloop_timeout_remaining(struct uloop_timeout *timeout); +int64_t uloop_timeout_remaining64(struct uloop_timeout *timeout); int uloop_process_add(struct uloop_process *p); int uloop_process_delete(struct uloop_process *p);