mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 17:55:07 -05:00
sys: add apply_step_offset function to generic driver
Move the generic code away from the Linux driver and keep there only stepping by adjtimex(ADJ_SETOFFSET).
This commit is contained in:
@@ -235,6 +235,28 @@ offset_convert(struct timeval *raw,
|
||||
*err = fabs(duration) <= max_freq_change_delay ? slew_error : 0.0;
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
/* Positive means currently fast of true time, i.e. jump backwards */
|
||||
|
||||
static void
|
||||
apply_step_offset(double offset)
|
||||
{
|
||||
struct timeval old_time, new_time;
|
||||
double err;
|
||||
|
||||
LCL_ReadRawTime(&old_time);
|
||||
UTI_AddDoubleToTimeval(&old_time, -offset, &new_time);
|
||||
|
||||
if (settimeofday(&new_time, NULL) < 0) {
|
||||
LOG_FATAL(LOGF_SysGeneric, "settimeofday() failed");
|
||||
}
|
||||
|
||||
LCL_ReadRawTime(&old_time);
|
||||
UTI_DiffTimevalsToDouble(&err, &old_time, &new_time);
|
||||
|
||||
lcl_InvokeDispersionNotifyHandlers(fabs(err));
|
||||
}
|
||||
|
||||
/* ================================================== */
|
||||
|
||||
void
|
||||
@@ -254,7 +276,8 @@ SYS_Generic_CompleteFreqDriver(double max_set_freq_ppm, double max_set_freq_dela
|
||||
offset_register = 0.0;
|
||||
|
||||
lcl_RegisterSystemDrivers(read_frequency, set_frequency,
|
||||
accrue_offset, sys_apply_step_offset,
|
||||
accrue_offset, sys_apply_step_offset ?
|
||||
sys_apply_step_offset : apply_step_offset,
|
||||
offset_convert, sys_set_leap);
|
||||
|
||||
LCL_AddParameterChangeHandler(handle_step, NULL);
|
||||
|
||||
Reference in New Issue
Block a user