sched/hrtimer: inline hrtimer_start.

This commit inlined the `hrtimer_start` to allow the compiler to optimize at least 1 branch in
hrtimer_start.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2026-01-26 16:46:42 +08:00
committed by Donny(董九柱)
parent fe184f79f3
commit 7b67055150
2 changed files with 21 additions and 22 deletions
+16 -2
View File
@@ -207,9 +207,23 @@ int hrtimer_cancel_sync(FAR hrtimer_t *hrtimer);
* OK on success; a negated errno value on failure.
****************************************************************************/
int hrtimer_start_absolute(FAR hrtimer_t *hrtimer, hrtimer_entry_t func,
uint64_t expired);
static inline_function
int hrtimer_start(FAR hrtimer_t *hrtimer, hrtimer_entry_t func,
uint64_t expired,
enum hrtimer_mode_e mode);
uint64_t expired, enum hrtimer_mode_e mode)
{
/* In most cases, the mode can be evaluated at compile time.
* The compiler will optimize the code to avoid the branch.
*/
uint64_t next_expired = mode == HRTIMER_MODE_ABS ? expired :
clock_systime_nsec() +
(expired <= HRTIMER_MAX_DELAY ?
expired : HRTIMER_MAX_DELAY);
return hrtimer_start_absolute(hrtimer, func, next_expired);
}
/****************************************************************************
* Name: hrtimer_gettime