Skip to content
Commit 21b8bd1b authored by Chris Friedt's avatar Chris Friedt Committed by Benjamin Cabé
Browse files

sys: timeutil: add utility functions for struct timespec



Add a number of utility functions for manipulating struct timespec.

* timespec_add()
* timespec_compare()
* timespec_equal()
* timespec_is_valid()
* timespec_negate()
* timespec_normalize()
* timespec_sub()
* timespec_from_timeout()
* timespec_to_timeout()

If the `__builtin_add_overflow()` function is available, then the
API is mostly branchless, which should provide decent performance on
systems with an instruction cache and branch prediction. Otherwise,
manually written alternatives exist that are also perhaps more
readable.

The two functions at the end convert time durations between
representation as `struct timespec` and `k_timeout_t`.

Signed-off-by: default avatarChris Friedt <cfriedt@tenstorrent.com>
parent 246c65bf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment