1/* Copyright (C) 1995-2019 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
17
18#ifndef _BITS_TIMEX_H
19#define _BITS_TIMEX_H 1
20
21#include <bits/types.h>
22#include <bits/types/struct_timeval.h>
23
24/* These definitions from linux/timex.h as of 3.18. */
25
26struct timex
27{
28 unsigned int modes; /* mode selector */
29 __syscall_slong_t offset; /* time offset (usec) */
30 __syscall_slong_t freq; /* frequency offset (scaled ppm) */
31 __syscall_slong_t maxerror; /* maximum error (usec) */
32 __syscall_slong_t esterror; /* estimated error (usec) */
33 int status; /* clock command/status */
34 __syscall_slong_t constant; /* pll time constant */
35 __syscall_slong_t precision; /* clock precision (usec) (ro) */
36 __syscall_slong_t tolerance; /* clock frequency tolerance (ppm) (ro) */
37 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */
38 __syscall_slong_t tick; /* (modified) usecs between clock ticks */
39 __syscall_slong_t ppsfreq; /* pps frequency (scaled ppm) (ro) */
40 __syscall_slong_t jitter; /* pps jitter (us) (ro) */
41 int shift; /* interval duration (s) (shift) (ro) */
42 __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */
43 __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */
44 __syscall_slong_t calcnt; /* calibration intervals (ro) */
45 __syscall_slong_t errcnt; /* calibration errors (ro) */
46 __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */
47
48 int tai; /* TAI offset (ro) */
49
50 /* ??? */
51 int :32; int :32; int :32; int :32;
52 int :32; int :32; int :32; int :32;
53 int :32; int :32; int :32;
54};
55
56/* Mode codes (timex.mode) */
57#define ADJ_OFFSET 0x0001 /* time offset */
58#define ADJ_FREQUENCY 0x0002 /* frequency offset */
59#define ADJ_MAXERROR 0x0004 /* maximum time error */
60#define ADJ_ESTERROR 0x0008 /* estimated time error */
61#define ADJ_STATUS 0x0010 /* clock status */
62#define ADJ_TIMECONST 0x0020 /* pll time constant */
63#define ADJ_TAI 0x0080 /* set TAI offset */
64#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */
65#define ADJ_MICRO 0x1000 /* select microsecond resolution */
66#define ADJ_NANO 0x2000 /* select nanosecond resolution */
67#define ADJ_TICK 0x4000 /* tick value */
68#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */
69#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */
70
71/* xntp 3.4 compatibility names */
72#define MOD_OFFSET ADJ_OFFSET
73#define MOD_FREQUENCY ADJ_FREQUENCY
74#define MOD_MAXERROR ADJ_MAXERROR
75#define MOD_ESTERROR ADJ_ESTERROR
76#define MOD_STATUS ADJ_STATUS
77#define MOD_TIMECONST ADJ_TIMECONST
78#define MOD_CLKB ADJ_TICK
79#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */
80#define MOD_TAI ADJ_TAI
81#define MOD_MICRO ADJ_MICRO
82#define MOD_NANO ADJ_NANO
83
84
85/* Status codes (timex.status) */
86#define STA_PLL 0x0001 /* enable PLL updates (rw) */
87#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */
88#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */
89#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */
90
91#define STA_INS 0x0010 /* insert leap (rw) */
92#define STA_DEL 0x0020 /* delete leap (rw) */
93#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */
94#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */
95
96#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */
97#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */
98#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */
99#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */
100
101#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */
102#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */
103#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */
104#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */
105
106/* Read-only bits */
107#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
108 STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK)
109
110#endif /* bits/timex.h */
111