shared: Add timespec_eq helper function

Add a helper function to check if two struct timespec values are equal.
This helper function will be used in upcoming commits that implement the
input_timestamps_unstable_v1 protocol.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
This commit is contained in:
Alexandros Frantzis
2018-02-16 18:44:14 +02:00
committed by Pekka Paalanen
parent 2d8331c4b7
commit 7a93bb2f17
2 changed files with 25 additions and 0 deletions
+13
View File
@@ -231,6 +231,19 @@ timespec_is_zero(const struct timespec *a)
return a->tv_sec == 0 && a->tv_nsec == 0;
}
/* Check if two timespecs are equal
*
* \param a[in] timespec to check
* \param b[in] timespec to check
* \return whether timespecs a and b are equal
*/
static inline bool
timespec_eq(const struct timespec *a, const struct timespec *b)
{
return a->tv_sec == b->tv_sec &&
a->tv_nsec == b->tv_nsec;
}
/* Convert milli-Hertz to nanoseconds
*
* \param mhz frequency in mHz, not zero