Leap second support

Leap second status is accepted and forwarded to clients if majority
of selectable sources agree. The actual insertion/deletion is supported
only on Linux now.
This commit is contained in:
Miroslav Lichvar
2008-12-31 09:59:20 +01:00
parent 0148ecaea0
commit 8f9c237010
13 changed files with 141 additions and 12 deletions

View File

@@ -39,6 +39,9 @@
#include "chrony_timex.h"
#include "wrap_adjtimex.h"
/* Save leap status between calls */
static int leap_status = 0;
int
TMX_SetTick(long tick)
{
@@ -73,6 +76,7 @@ TMX_SetFrequency(double freq, long tick)
txc.tick = tick;
txc.status = STA_UNSYNC; /* Prevent any of the FLL/PLL stuff coming
up */
txc.status |= leap_status; /* Preserve leap bits */
return adjtimex(&txc);
}
@@ -144,5 +148,24 @@ TMX_ReadCurrentParams(struct tmx_params *params)
return result;
}
int
TMX_SetLeap(int leap)
{
struct timex txc;
if (leap > 0) {
leap_status = STA_INS;
} else if (leap < 0) {
leap_status = STA_DEL;
} else {
leap_status = 0;
}
txc.modes = ADJ_STATUS;
txc.status = STA_UNSYNC | leap_status;
return adjtimex(&txc);
}
#endif