adjtimex(2) System Calls Manual adjtimex(2) adjtimex, clock_adjtime, ntp_adjtime - (libc -lc) #include int adjtimex(struct timex *buf); int clock_adjtime(clockid_t clk_id, struct timex *buf); int ntp_adjtime(struct timex *buf); . ( RFC 5905). adjtimex() . timex () . : struct timex { int modes; /* Mode selector */ long offset; /* Time offset; nanoseconds, if STA_NANO status flag is set, otherwise microseconds */ long freq; /* Frequency offset; see NOTES for units */ long maxerror; /* Maximum error (microseconds) */ long esterror; /* Estimated error (microseconds) */ int status; /* Clock command/status */ long constant; /* PLL (phase-locked loop) time constant */ long precision; /* Clock precision (microseconds, read-only) */ long tolerance; /* Clock frequency tolerance (read-only); see NOTES for units */ struct timeval time; /* Current time (read-only, except for ADJ_SETOFFSET); upon return, time.tv_usec contains nanoseconds, if STA_NANO status flag is set, otherwise microseconds */ long tick; /* Microseconds between clock ticks */ long ppsfreq; /* PPS (pulse per second) frequency (read-only); see NOTES for units */ long jitter; /* PPS jitter (read-only); nanoseconds, if STA_NANO status flag is set, otherwise microseconds */ int shift; /* PPS interval duration (seconds, read-only) */ long stabil; /* PPS stability (read-only); see NOTES for units */ long jitcnt; /* PPS count of jitter limit exceeded events (read-only) */ long calcnt; /* PPS count of calibration intervals (read-only) */ long errcnt; /* PPS count of calibration errors (read-only) */ long stbcnt; /* PPS count of stability limit exceeded events (read-only) */ int tai; /* TAI offset, as set by previous ADJ_TAI operation (seconds, read-only, since Linux 2.6.26) */ /* Further padding bytes to allow for future expansion */ }; modes . ( ntp_adjtime() .) OR : ADJ_OFFSET buf.offset. 2.6.26 (-0.5s, +0.5s). EINVAL . ADJ_FREQUENCY buf.freq. 2.6.26 (-32768000, +32768000). EINVAL . ADJ_MAXERROR buf.maxerror. ADJ_ESTERROR buf.esterror. ADJ_STATUS buf.status. . ADJ_TIMECONST PLL buf.constant. STA_NANO ( ) 4 . ADJ_SETOFFSET ( 2.6.39) buf.time . buf.status ADJ_NANO buf.time.tv_usec . buf.time buf.time.tv_usec . timeval . while (buf.time.tv_usec < 0) { buf.time.tv_sec -= 1; buf.time.tv_usec += 1000000000; } ADJ_MICRO ( 2.6.26) . ADJ_NANO ( 2.6.26) . ADJ_MICRO ADJ_NANO. ADJ_TAI ( 2.6.26) TAI ( ) buf.constant. ADJ_TAI ADJ_TIMECONST buf.constant. TAI TAI UTC BIPM ADJ_TICK buf.tick. modes ( ) modes: ADJ_OFFSET_SINGLESHOT adjtime(3) : () buf.offset . ADJ_OFFSET_SS_READ ( Linux 2.6.28) ( buf.offset) ADJ_OFFSET_SINGLESHOT . Linux 2.6.24 Linux 2.6.28. 0 ADJ_OFFSET_SS_READ modes. . buf.status / NTP. . STA_PLL (-) (PLL) ADJ_OFFSET. STA_PPSFREQ (-) (PPS). STA_PPSTIME (-) (PPS). STA_FLL (-) (FLL). STA_INS (-) UTC . . STA_DEL (-) UTC. . STA_UNSYNC (-) . STA_FREQHOLD (-) . ADJ_OFFSET . . ADJ_OFFSET. STA_PPSSIGNAL ( ) (PPS) . STA_PPSJITTER ( ) PPS. STA_PPSWANDER ( ) PPS. STA_PPSERROR ( ) PPS. STA_CLOCKERR ( ) . STA_NANO ( 2.6.26) (0 = 1 = ). ADJ_NANO ADJ_MICRO. STA_MODE ( 2.6.26) (0 = 1 = ). STA_CLK ( 2.6.26) (0 = A 1 = B) . status . clock_adjtime () clock_adjtime() ( 2.6.39) adjtimex() clk_id . ntp_adjtime () ntp_adjtime() ( " " NTP KAPI) adjtimex(). adjtimex(): o modes "MOD_" "ADJ_" ( MOD_OFFSET MOD_FREQUENCY ) . o MOD_CLKA ADJ_OFFSET_SINGLESHOT. o MOD_CLKB ADJ_TICK. o ADJ_OFFSET_SS_READ KAPI. adjtimex() ntp_adjtime() : TIME_OK . TIME_INS UTC. TIME_DEL UTC. TIME_OOP . TIME_WAIT . ADJ_STATUS STA_INS STA_DEL. TIME_ERROR . : o STA_UNSYNC STA_CLOCKERR . o STA_PPSSIGNAL STA_PPSFREQ STA_PPSTIME . o STA_PPSTIME STA_PPSJITTER . o STA_PPSFREQ STA_PPSWANDER STA_PPSJITTER . TIME_BAD TIME_ERROR . 3.4 . -1 errno . EFAULT buf . EINVAL ( 2.6.26) buf.freq (-33554432, +33554432). EINVAL ( 2.6.26) buf.offset . 2.0 (-131072, +131072). 2.0 (-512000, +512000). EINVAL buf.status . EINVAL clk_id clock_adjtime() . System-V clk_id . clock_gettime(2) . EINVAL buf.tick 900000/HZ 1100000/HZ HZ . ENODEV ( USB ) clk_id . clock_gettime(2) . EOPNOTSUPP clk_id . EPERM buf.modes 0 ADJ_OFFSET_SS_READ . CAP_SYS_TIME. attributes(7). +------------+------------------------------------+--------------------+ || | | +------------+------------------------------------+--------------------+ |ntp_adjtime()| | MT-Safe | +------------+------------------------------------+--------------------+ adjtimex() clock_adjtime() . NTP ntp_adjtime(). timex freq ppsfreq stabil ppm ( ) 16 1 2^-16 ppm 2^16=65536 1 ppm. ( freq) . STA_INS STA_DEL . . clock_gettime(2), clock_settime(2), settimeofday(2), adjtime(3), ntp_gettime(3), capabilities(7), time(7), adjtimex(8), hwclock(8) NTP " " 3 . . : . 6.18 8 2026 adjtimex(2)