timepoints: minimal compatibility with CONFIG_SYS_CLOCK_EXISTS=n
When timers are configured out, timepoint-based timeouts are reduced to "no wait" or "wait forever" only. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
9fab38dd04
commit
90eac6e4bc
1 changed files with 39 additions and 13 deletions
|
@ -190,6 +190,8 @@ int64_t sys_clock_tick_get(void);
|
|||
#define sys_clock_tick_get_32() (0)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SYS_CLOCK_EXISTS
|
||||
|
||||
/**
|
||||
* @brief Kernel timepoint type
|
||||
*
|
||||
|
@ -235,19 +237,6 @@ k_timepoint_t sys_timepoint_calc(k_timeout_t timeout);
|
|||
*/
|
||||
k_timeout_t sys_timepoint_timeout(k_timepoint_t timepoint);
|
||||
|
||||
/**
|
||||
* @brief Indicates if timepoint is expired
|
||||
*
|
||||
* @param timepoint Timepoint to evaluate
|
||||
* @retval true if the timepoint is in the past, false otherwise
|
||||
*
|
||||
* @see sys_timepoint_calc()
|
||||
*/
|
||||
static inline bool sys_timepoint_expired(k_timepoint_t timepoint)
|
||||
{
|
||||
return K_TIMEOUT_EQ(sys_timepoint_timeout(timepoint), Z_TIMEOUT_NO_WAIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Provided for backward compatibility.
|
||||
*
|
||||
|
@ -263,6 +252,43 @@ static inline uint64_t sys_clock_timeout_end_calc(k_timeout_t timeout)
|
|||
return tp.tick;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* When timers are configured out, timepoints can't relate to anything.
|
||||
* The best we can do is to preserve whether or not they are derived from
|
||||
* K_NO_WAIT. Anything else will translate back to K_FOREVER.
|
||||
*/
|
||||
typedef struct { bool wait; } k_timepoint_t;
|
||||
|
||||
static inline k_timepoint_t sys_timepoint_calc(k_timeout_t timeout)
|
||||
{
|
||||
k_timepoint_t timepoint;
|
||||
|
||||
timepoint.wait = !K_TIMEOUT_EQ(timeout, Z_TIMEOUT_NO_WAIT);
|
||||
return timepoint;
|
||||
}
|
||||
|
||||
static inline k_timeout_t sys_timepoint_timeout(k_timepoint_t timepoint)
|
||||
{
|
||||
return timepoint.wait ? Z_FOREVER : Z_TIMEOUT_NO_WAIT;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Indicates if timepoint is expired
|
||||
*
|
||||
* @param timepoint Timepoint to evaluate
|
||||
* @retval true if the timepoint is in the past, false otherwise
|
||||
*
|
||||
* @see sys_timepoint_calc()
|
||||
*/
|
||||
static inline bool sys_timepoint_expired(k_timepoint_t timepoint)
|
||||
{
|
||||
return K_TIMEOUT_EQ(sys_timepoint_timeout(timepoint), Z_TIMEOUT_NO_WAIT);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue