/* Next needed call to sys_clock_announce will not be until the specified number of ticks from the current time have elapsed.  */
void sys_clock_set_timeout(int32_t ticks, bool idle)
/* Next needed call to sys_clock_announce will not be until the specified number of ticks from the current time have elapsed.  */
void sys_clock_set_timeout(int32_t ticks, bool idle)
{
	if (!IS_ENABLED(CONFIG_TICKLESS_KERNEL)) {
		return;
	}
	k_spinlock_key_t key;
	uint32_t next, adj, now;
	ticks = (ticks == K_TICKS_FOREVER) ? MAX_TICKS : ticks;
	ticks = CLAMP((ticks - 1), 0, (int32_t)MAX_TICKS);
	key = k_spin_lock(&lock);
	now = GPT_GetCurrentTimerCount(base);
	adj = (now - announced_cycles) + (CYC_PER_TICK - 1);
	next = ticks * CYC_PER_TICK;
	next += adj;
	next = (next / CYC_PER_TICK) * CYC_PER_TICK;
	next += announced_cycles;
	gpt_set_safe(next);
	k_spin_unlock(&lock, key);
}