You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Dead code in aon_timer.c: aon_timer_enable_alarm function (the implementation for the powman timer) #3273
In the function for setting alarms using the POWMAN timer, the variable ts_adjusted is declared to (it appears) round the time up to the nearest ms*. But then the timer is set using the ts that was passed to the function originally, discarding the value of ts_adjusted.
*that isn't what would actually happen if ts_adjusted were used to set the alarm, but it looks to me like the intended behavior.
I'm happy to make a pull request that fixes this issue, but I'd like to know what the intended behavior is. Should the alarm time be rounded up to the nearest ms (appears to be the intended behavior), or rounded down to the nearest ms (appears to be the actual current behavior)?
If the intended behavior is to round down, I'd delete lines 128-133 and the declaration of ts_adjusted, and if the intended behavior is to round up I'd probably replace lines 128-133 with something like:
if (ts_adjusted.tv_nsec % 1000000) ts_adjusted.tv_nsec+=1000000;
That way if tv_nsec is an exact number of ms, the alarm will be set to exactly the time requested, but if not, the time will be incremented by 1 ms and then the trailing digits will be truncated by timespec_to_ms (for example if tv_nsec = 999999 it will be incremented to 1999999, and then later truncated to 1 ms)
Activity
NanoExplorer commentedon Oct 20, 2026
If the intended behavior is to round down, I'd delete lines 128-133 and the declaration of
ts_adjusted, and if the intended behavior is to round up I'd probably replace lines 128-133 with something like:That way if
tv_nsecis an exact number of ms, the alarm will be set to exactly the time requested, but if not, the time will be incremented by 1 ms and then the trailing digits will be truncated bytimespec_to_ms(for example iftv_nsec =999999 it will be incremented to 1999999, and then later truncated to 1 ms)