Add a macro for ADJ_TAI used when missing from the tool chain headers.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
phc2sys: track sync offset and leap second status in each clock.

This simplifies passing of pending leap seconds to the clocks and it
will also allow to apply leap second to other clocks than system clock
if needed in future.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Set TAI offset of system clock.

When synchronizing the system clock and the PTP UTC offset is valid and
traceable, set the TAI offset of the clock to have correct CLOCK_TAI
(which is implemented in the kernel as CLOCK_REALTIME + TAI offset).

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
phc2sys: Use CLOCK_MONOTONIC to time pmc updates.

After moving the leap second check away from update_pmc(), the time
stamp is used only to control the pmc update interval. Switch to
CLOCK_MONOTONIC to keep the interval stable when CLOCK_REALTIME is
stepped.
Add leap function to servo.

Introduce a new function to inform the servo about upcoming leap second.
This is used when the kernel leap is disabled to allow the servo to
handle better the sudden 1 second step in the offset when the leap
second is inserted or deleted.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
ntpshm: Pass upcoming leap second.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
linreg: Handle leap second gracefully.

When leap second is inserted/deleted to the reference time, adjust the
reference point as if the clock was stepped in the opposite direction to
keep the slope and error statistics valid and correct the offset
gracefully.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
Disable clockcheck and kernel leap with ntpshm servo.

Always disable the clock sanity check when the ntpshm servo is used,
because it doesn't know when or how is the clock adjusted. Disable also
the kernel leap option as the process controlling the clock is
responsible for setting the kernel flag.

Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>