Commit graph

14 commits

Author SHA1 Message Date
Derek Foreman 5079f0b2f9 helpers: Add a u64 from 2 u32 helper
We do this enough that having a single implementation for it is probably
a win.

Signed-off-by: Derek Foreman <derek.foreman@collabora.com>
2022-10-27 08:13:30 +00:00
Daniel Stone a9278d28fc timespec: Don't return value from void function
timespec_add_msec() doesn't return any values, so don't try to return
any.

Signed-off-by: Daniel Stone <daniels@collabora.com>
2019-06-11 11:31:04 +01:00
Alexandros Frantzis 7a93bb2f17 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>
2018-02-20 10:20:29 +02:00
Alexandros Frantzis 10d708d268 shared: Add timespec_to_proto helper function
Add helper function to convert from struct timespec values to tv_sec_hi,
tv_sec_lo, tv_nsec triplets used for sending high-resolution timestamp
data over the wayland protocol. 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>
2017-12-18 11:27:43 +02:00
Alexandros Frantzis 787fa611de 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>
2017-12-18 11:27:43 +02:00
Alexandros Frantzis 6c2752a863 shared: Add helpers to convert between various time units and timespec
Add helper functions to make it easy and less error-prone to convert
between values in various time units (nsec, usec, msec) and struct
timespec. These helpers are going to be used in the upcoming commits to
transition the Weston codebase to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:18:25 +02:00
Alexandros Frantzis e2a5f9e02d shared: Add timespec_is_zero helper
Add a helper function to check if a struct timespec is zero. This helper
will be used in the upcoming commits to transition the Weston codebase
to struct timespec.

Signed-off-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-11-27 11:18:25 +02:00
Yann E. MORIN fa41bdfbc0 shared: struct timespec is in time.h
On the musl C library, tests/timespec-text.c does not build, with the
following error:

    In file included from tests/timespec-test.c:36:0:
    ./shared/timespec-util.h:41:21: warning: ‘struct timespec’ declared
    inside parameter list will not be visible outside of this definition
    or declaration
     timespec_sub(struct timespec *r,
                         ^~~~~~~~
   [...]

Indeed, struct timespec is defined in time.h, so we must include it.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-10-02 12:19:18 +03:00
Daniel Stone 839b63546d timespec: Add timespec subtraction helpers
Add helpers to subtract two timespecs, then return the difference in
either milliseconds or nanoseconds. These will be used to compare
timestamps during the repaint cycle.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Suggested-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-13 14:20:06 +02:00
Daniel Stone 37ad7e3bae timespec: Add timespec_to_msec helper
Paralleling timespec_to_nsec, converts to milliseconds.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
[Pekka: added doc about flooring]
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-13 14:19:46 +02:00
Daniel Stone 61f6d7d372 timespec: Add timespec_add_msec helper
Add a (timespec) = (timespec) + (msec) helper, to save intermediate
conversions in its users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-08 11:57:34 +02:00
Daniel Stone 5ae7e84c6b timespec: Add timespec_add_nsec helper
Add a (timespec) = (timespec) + (nsec) helper, to save intermediate
conversions to nanoseconds in its users.

Signed-off-by: Daniel Stone <daniels@collabora.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2017-03-08 11:57:34 +02:00
Pekka Paalanen d7894d052a compositor,shared: add millihz_to_nsec()
A helper to improbe readability.

Cc: Daniel Stone <daniels@collabora.com>
Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-16 13:55:05 +03:00
Pekka Paalanen aa21f6249f shared: introduce timespec-util.h
Copyright is set according to the moved code from compositor.c.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
2015-07-16 13:55:05 +03:00