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

sys: clock: additional constants and macros for timespec conversion



Define additional constants and macros for converting between timespec
objects and k_timeout_t.

There are four semantically important durations identified with new
constants identified via '.

1. K_NO_WAIT / K_TIMESPEC_NO_WAIT'
  *  duration of zero

2. K_TICK_MIN' / K_TIMESPEC_MIN'
  * minimum number of ticks strictly greater than K_NO_WAIT

3. K_TICK_MAX' / K_TIMESPEC_MAX'
  * maximum number of ticks strictly and semantically less than K_FOREVER

4. K_FOREVER / K_TIMESPEC_FOREVER'
  * the familiar non-expiring number of ticks (i.e. infinity)

With these definitions, there are 3 meaningful regions for conversion
between timespec and k_timeout_t representation:

1. < K_TIMESPEC_NO_WAIT (i.e. a negative timespec)
  * should be rounded up to K_TIMESPEC_NO_WAIT
  * < K_NO_WAIT in ticks is an absolute time point in 64-bit
    representation should no be permitted in the affected conversion
    routines, as they are explicitly  for converting time durations rather
    than absolute time points.

2. K_TIMESPEC_NO_WAIT < x < K_TIMESPEC_MAX
  * should be rounded-up to the next tick boundary
  * must be represented as the minimal non-zero duration in ticks

3. K_TIMESPEC_MAX <= x < K_TIMESPEC_FOREVER
  * must be represented as the maximum expiring duration in ticks
  * should be rounded-down to K_TIMESPEC_MAX

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