summaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorAlexandros Frantzis <alexandros.frantzis@collabora.com>2017-12-13 13:27:53 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2017-12-18 11:27:43 +0200
commit787fa611de1b7c4144b7491260c513a5ec0a4728 (patch)
tree8417d4dfcf7f13ce9c2b18ada1400ef7105b5a2c /shared
parentc83fdaa55568b1177f8f4752a5ce352fd0c32a69 (diff)
downloadweston-787fa611de1b7c4144b7491260c513a5ec0a4728.tar.gz
shared: Add timespec_from_proto helper function
Add helper function to convert tv_sec_hi, tv_sec_lo, tv_nsec triplets, used for sending high-resolution timestamp data over the wayland protocol, to struct timespec values. Replace existing conversion code with the helper function. 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.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/shared/timespec-util.h b/shared/timespec-util.h
index f9736c27..5184d281 100644
--- a/shared/timespec-util.h
+++ b/shared/timespec-util.h
@@ -181,6 +181,21 @@ timespec_from_msec(struct timespec *a, int64_t b)
timespec_from_nsec(a, b * 1000000);
}
+/* Convert protocol data to timespec
+ *
+ * \param a[out] timespec
+ * \param tv_sec_hi the high bytes of seconds part
+ * \param tv_sec_lo the low bytes of seconds part
+ * \param tv_nsec the nanoseconds part
+ */
+static inline void
+timespec_from_proto(struct timespec *a, uint32_t tv_sec_hi,
+ uint32_t tv_sec_lo, uint32_t tv_nsec)
+{
+ a->tv_sec = ((uint64_t)tv_sec_hi << 32) + tv_sec_lo;
+ a->tv_nsec = tv_nsec;
+}
+
/* Check if a timespec is zero
*
* \param a timespec