NAME
ntp_adjtime – NTP daemon application interface
SYNOPSIS
#include <sys/types.h>
#include <sys/timex.h>
int
ntp_adjtime(struct timex *tp);
DESCRIPTION
The ntp_adjtime() system call is used as a kernel interface for the Network Time Protocol daemon, ntpd(8). Certain fields of the timex structure are interpreted in either microseconds or nanoseconds, according to the state of the STA_NANO bit in the status word.
In the FreeBSD kernel, the ntp_adjtime() and ntp_gettime(2) system calls can be used to determine which resolution is in use, and to select either one at any time. The resolution selected affects the scaling of certain fields in the ntp_gettime() and ntp_adjtime() system calls.
Take note that this API is extremely complex and stateful. Users should not attempt modification without first reviewing the ntpd(8) sources in depth.
/*
* NTP daemon interface (ntp_adjtime()) - used to discipline CPU clock
* oscillator and determine status.
*
* Note: The offset, precision and jitter members are in microseconds if
* STA_NANO is zero and nanoseconds if not.
*/
struct timex {
unsigned int modes; /* clock mode bits (wo) */
long offset; /* time offset (ns/us) (rw) */
long freq; /* frequency offset (scaled PPM) (rw) */
long maxerror; /* maximum error (us) (rw) */
long esterror; /* estimated error (us) (rw) */
int status; /* clock status bits (rw) */
long constant; /* poll interval (log2 s) (rw) */
long precision; /* clock precision (ns/us) (ro) */
long tolerance; /* clock frequency tolerance (scaled
* PPM) (ro) */
/*
* The following read-only structure members are implemented
* only if the PPS signal discipline is configured in the
* kernel. They are included in all configurations to insure
* portability.
*/
long ppsfreq; /* PPS frequency (scaled PPM) (ro) */
long jitter; /* PPS jitter (ns/us) (ro) */
int shift; /* interval duration (s) (shift) (ro) */
long stabil; /* PPS stability (scaled PPM) (ro) */
long jitcnt; /* jitter limit exceeded (ro) */
long calcnt; /* calibration intervals (ro) */
long errcnt; /* calibration errors (ro) */
long stbcnt; /* stability limit exceeded (ro) */
};
Upon successful completion, ntp_adjtime() will fill the tp argument with the current clock state.
RETURN VALUES
Upon successful completion the clock state is returned. Otherwise a -1 is returned and the global variable errno is set to indicate the error.
Possible states of the clock are:
- TIME_OK
-
Everything okay, no leap second warning.
- TIME_INS
-
insert leap second warning.
- TIME_DEL
-
delete leap second warning.
- TIME_OOP
-
Leap second in progress.
- TIME_WAIT
-
Leap second has occurred.
- TIME_ERROR
-
Clock not synchronized.
ERRORS
The ntp_gettime() system call may return EPERM if the caller does not have sufficient permissions.
SEE ALSO
AUTHORS
This manual page was written by Tom Rhodes ⟨[email protected]⟩.