#include <sys/timex.h>

sys/timex.h

44 macros · 2 structs · 2 functions

macroNTP_API

#define NTP_API 4
NTP API version

macroMAXPHASE

#define MAXPHASE 500000000L
max phase error (ns)

macroMAXFREQ

#define MAXFREQ 500000L
max freq error (ns/s)

macroMINSEC

#define MINSEC 256
min FLL update interval (s)

macroMAXSEC

#define MAXSEC 2048
max PLL update interval (s)

macroNANOSECOND

#define NANOSECOND 1000000000L
nanoseconds in one second

macroSCALE_PPM

#define SCALE_PPM (65536 / 1000)
crude ns/s to scaled PPM

macroMAXTC

#define MAXTC 10
max time constant

macroMOD_OFFSET

Control mode codes (timex.modes)
#define MOD_OFFSET 0x0001
set time offset

macroMOD_FREQUENCY

#define MOD_FREQUENCY 0x0002
set frequency offset

macroMOD_MAXERROR

#define MOD_MAXERROR 0x0004
set maximum time error

macroMOD_ESTERROR

#define MOD_ESTERROR 0x0008
set estimated time error

macroMOD_STATUS

#define MOD_STATUS 0x0010
set clock status bits

macroMOD_TIMECONST

#define MOD_TIMECONST 0x0020
set PLL time constant

macroMOD_PPSMAX

#define MOD_PPSMAX 0x0040
set PPS maximum averaging time

macroMOD_TAI

#define MOD_TAI 0x0080
set TAI offset

macroMOD_MICRO

#define MOD_MICRO 0x1000
select microsecond resolution

macroMOD_NANO

#define MOD_NANO 0x2000
select nanosecond resolution

macroMOD_CLKB

#define MOD_CLKB 0x4000
select clock B

macroMOD_CLKA

#define MOD_CLKA 0x8000
select clock A

macroSTA_PLL

Status codes (timex.status)
#define STA_PLL 0x0001
enable PLL updates (rw)

macroSTA_PPSFREQ

#define STA_PPSFREQ 0x0002
enable PPS freq discipline (rw)

macroSTA_PPSTIME

#define STA_PPSTIME 0x0004
enable PPS time discipline (rw)

macroSTA_FLL

#define STA_FLL 0x0008
enable FLL mode (rw)

macroSTA_INS

#define STA_INS 0x0010
insert leap (rw)

macroSTA_DEL

#define STA_DEL 0x0020
delete leap (rw)

macroSTA_UNSYNC

#define STA_UNSYNC 0x0040
clock unsynchronized (rw)

macroSTA_FREQHOLD

#define STA_FREQHOLD 0x0080
hold frequency (rw)

macroSTA_PPSSIGNAL

#define STA_PPSSIGNAL 0x0100
PPS signal present (ro)

macroSTA_PPSJITTER

#define STA_PPSJITTER 0x0200
PPS signal jitter exceeded (ro)

macroSTA_PPSWANDER

#define STA_PPSWANDER 0x0400
PPS signal wander exceeded (ro)

macroSTA_PPSERROR

#define STA_PPSERROR 0x0800
PPS signal calibration error (ro)

macroSTA_CLOCKERR

#define STA_CLOCKERR 0x1000
clock hardware fault (ro)

macroSTA_NANO

#define STA_NANO 0x2000
resolution (0 = us, 1 = ns) (ro)

macroSTA_MODE

#define STA_MODE 0x4000
mode (0 = PLL, 1 = FLL) (ro)

macroSTA_CLK

#define STA_CLK 0x8000
clock source (0 = A, 1 = B) (ro)

macroTIME_OK

Clock states (ntptimeval.time_state)
#define TIME_OK 0
no leap second warning

macroTIME_INS

#define TIME_INS 1
insert leap second warning

macroTIME_DEL

#define TIME_DEL 2
delete leap second warning

macroTIME_OOP

#define TIME_OOP 3
leap second in progress

macroTIME_WAIT

#define TIME_WAIT 4
leap second has occurred

macroTIME_ERROR

#define TIME_ERROR 5
error (see status word)

structntptimeval

NTP user interface -- ntp_gettime - used to read kernel clock values
size 48, align 8
struct timespectimecurrent time (ns) (ro)
longmaxerrormaximum error (us) (ro)
longesterrorestimated error (us) (ro)
longtaiTAI offset
inttime_statetime status

structtimex

NTP daemon interface -- ntp_adjtime -- used to discipline CPU clock oscillator and control/determine status. Note: The offset, precision and jitter members are in microseconds if STA_NANO is zero and nanoseconds if not.
size 136, align 8
unsigned intmodesclock mode bits (wo)
longoffsettime offset (ns/us) (rw)
longfreqfrequency offset (scaled PPM) (rw)
longmaxerrormaximum error (us) (rw)
longesterrorestimated error (us) (rw)
intstatusclock status bits (rw)
longconstantpoll interval (log2 s) (rw)
longprecisionclock precision (ns/us) (ro)
longtoleranceclock frequency tolerance (scaled PPM) (ro)
longppsfreqThe following read-only structure members are used by the PPS signal discipline that is currently not supported. They are included for compatibility. PPS frequency (scaled PPM) (ro)
longjitterPPS jitter (ns/us) (ro)
intshiftinterval duration (s) (shift) (ro)
longstabilPPS stability (scaled PPM) (ro)
longjitcntjitter limit exceeded (ro)
longcalcntcalibration intervals (ro)
longerrcntcalibration errors (ro)
longstbcntstability limit exceeded (ro)

functionntp_adjtime

int ntp_adjtime(struct timex *)

functionntp_gettime

int ntp_gettime(struct ntptimeval *)