summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>2018-02-16 18:44:14 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2018-02-20 10:20:29 +0200
commit7a93bb2f17137d1f97e66904cea9ea5e5f408d2a (patch)
treec78976e2af5a591278adbff6462c9b177a0df9fc /shared
parent2d8331c4b7f5ae865b0fefc14a4ada1a2b7b778c (diff)
downloadweston-7a93bb2f17137d1f97e66904cea9ea5e5f408d2a.tar.gz
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>
Diffstat (limited to 'shared')
-rw-r--r--shared/timespec-util.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/shared/timespec-util.h b/shared/timespec-util.h
index 5f4b2b9e..ca0156af 100644
--- a/shared/timespec-util.h
+++ b/shared/timespec-util.h
@@ -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