mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-10-29 05:40:16 -04:00
timespec: Pull in timespec_after and timespec_add from mesa
Signed-off-by: Sebastian Wick <sebastian.wick@redhat.com>
This commit is contained in:
parent
37469d5ced
commit
9d5de6062b
1 changed files with 34 additions and 0 deletions
|
|
@ -256,4 +256,38 @@ millihz_to_nsec(uint32_t mhz)
|
|||
return 1000000000000LL / mhz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether a timespec value is after another
|
||||
*
|
||||
* \param a[in] timespec to compare
|
||||
* \param b[in] timespec to compare
|
||||
* \return whether a is after b
|
||||
*/
|
||||
static inline bool
|
||||
timespec_after(const struct timespec *a, const struct timespec *b)
|
||||
{
|
||||
return (a->tv_sec == b->tv_sec) ?
|
||||
(a->tv_nsec > b->tv_nsec) :
|
||||
(a->tv_sec > b->tv_sec);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add timespecs
|
||||
*
|
||||
* \param r[out] result: a + b
|
||||
* \param a[in] operand
|
||||
* \param b[in] operand
|
||||
*/
|
||||
static inline void
|
||||
timespec_add(struct timespec *r,
|
||||
const struct timespec *a, const struct timespec *b)
|
||||
{
|
||||
r->tv_sec = a->tv_sec + b->tv_sec;
|
||||
r->tv_nsec = a->tv_nsec + b->tv_nsec;
|
||||
if (r->tv_nsec > NSEC_PER_SEC) {
|
||||
r->tv_sec++;
|
||||
r->tv_nsec -= NSEC_PER_SEC;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* TIMESPEC_UTIL_H */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue