Re: [PATCH] timeout: add l_timeout_get_remaining
Denis Kenzior <[email protected]> Wed, 28 Aug 2024 14:10:49 -0500
| Newsgroups | dev.linux.lists.ell |
|---|---|
| Message-ID | <[email protected]> |
Hi James,
> +LIB_EXPORT bool l_timeout_get_remaining(struct l_timeout *timeout,
> + uint64_t *remaining)
Lets call this l_timeout_remaining()
> +{
> + struct itimerspec current;
> +
> + if (unlikely(!timeout))
> + return false;
> +
> + if (timerfd_gettime(timeout->fd, ¤t) < 0)
> + return false;
> +
> + if (remaining)
> + *remaining = current.it_value.tv_sec * L_USEC_PER_SEC +
> + current.it_value.tv_nsec / L_NSEC_PER_USEC;
Can we use _time_from_timespec? Or maybe add that to time-private.h?
> +
> + return true;
> +}
Regards,
-Denis