1/* Copyright (C) 1995-2022 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 <https://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# if defined __USE_TIME_BITS64 || (__TIMESIZE == 64 && __WORDSIZE == 32) 
29 unsigned int modes; /* mode selector */ 
30 int :32; /* pad */ 
31 long long offset; /* time offset (usec) */ 
32 long long freq; /* frequency offset (scaled ppm) */ 
33 long long maxerror; /* maximum error (usec) */ 
34 long long esterror; /* estimated error (usec) */ 
35 int status; /* clock command/status */ 
36 int :32; /* pad */ 
37 long long constant; /* pll time constant */ 
38 long long precision; /* clock precision (usec) (read only) */ 
39 long long tolerance; /* clock frequency tolerance (ppm) (ro) */ 
40 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */ 
41 long long tick; /* (modified) usecs between clock ticks */ 
42 long long ppsfreq; /* pps frequency (scaled ppm) (ro) */ 
43 long long jitter; /* pps jitter (us) (ro) */ 
44 int shift; /* interval duration (s) (shift) (ro) */ 
45 int :32; /* pad */ 
46 long long stabil; /* pps stability (scaled ppm) (ro) */ 
47 long long jitcnt; /* jitter limit exceeded (ro) */ 
48 long long calcnt; /* calibration intervals (ro) */ 
49 long long errcnt; /* calibration errors (ro) */ 
50 long long stbcnt; /* stability limit exceeded (ro) */ 
51 
52 int tai; /* TAI offset (ro) */ 
53 
54 int :32; int :32; int :32; int :32
55 int :32; int :32; int :32; int :32
56 int :32; int :32; int :32
57# else 
58 unsigned int modes; /* mode selector */ 
59 __syscall_slong_t offset; /* time offset (usec) */ 
60 __syscall_slong_t freq; /* frequency offset (scaled ppm) */ 
61 __syscall_slong_t maxerror; /* maximum error (usec) */ 
62 __syscall_slong_t esterror; /* estimated error (usec) */ 
63 int status; /* clock command/status */ 
64 __syscall_slong_t constant; /* pll time constant */ 
65 __syscall_slong_t precision; /* clock precision (usec) (ro) */ 
66 __syscall_slong_t tolerance; /* clock frequency tolerance (ppm) (ro) */ 
67 struct timeval time; /* (read only, except for ADJ_SETOFFSET) */ 
68 __syscall_slong_t tick; /* (modified) usecs between clock ticks */ 
69 __syscall_slong_t ppsfreq; /* pps frequency (scaled ppm) (ro) */ 
70 __syscall_slong_t jitter; /* pps jitter (us) (ro) */ 
71 int shift; /* interval duration (s) (shift) (ro) */ 
72 __syscall_slong_t stabil; /* pps stability (scaled ppm) (ro) */ 
73 __syscall_slong_t jitcnt; /* jitter limit exceeded (ro) */ 
74 __syscall_slong_t calcnt; /* calibration intervals (ro) */ 
75 __syscall_slong_t errcnt; /* calibration errors (ro) */ 
76 __syscall_slong_t stbcnt; /* stability limit exceeded (ro) */ 
77 
78 int tai; /* TAI offset (ro) */ 
79 
80 /* ??? */ 
81 int :32; int :32; int :32; int :32
82 int :32; int :32; int :32; int :32
83 int :32; int :32; int :32
84# endif 
85}; 
86 
87/* Mode codes (timex.mode) */ 
88#define ADJ_OFFSET 0x0001 /* time offset */ 
89#define ADJ_FREQUENCY 0x0002 /* frequency offset */ 
90#define ADJ_MAXERROR 0x0004 /* maximum time error */ 
91#define ADJ_ESTERROR 0x0008 /* estimated time error */ 
92#define ADJ_STATUS 0x0010 /* clock status */ 
93#define ADJ_TIMECONST 0x0020 /* pll time constant */ 
94#define ADJ_TAI 0x0080 /* set TAI offset */ 
95#define ADJ_SETOFFSET 0x0100 /* add 'time' to current time */ 
96#define ADJ_MICRO 0x1000 /* select microsecond resolution */ 
97#define ADJ_NANO 0x2000 /* select nanosecond resolution */ 
98#define ADJ_TICK 0x4000 /* tick value */ 
99#define ADJ_OFFSET_SINGLESHOT 0x8001 /* old-fashioned adjtime */ 
100#define ADJ_OFFSET_SS_READ 0xa001 /* read-only adjtime */ 
101 
102/* xntp 3.4 compatibility names */ 
103#define MOD_OFFSET ADJ_OFFSET 
104#define MOD_FREQUENCY ADJ_FREQUENCY 
105#define MOD_MAXERROR ADJ_MAXERROR 
106#define MOD_ESTERROR ADJ_ESTERROR 
107#define MOD_STATUS ADJ_STATUS 
108#define MOD_TIMECONST ADJ_TIMECONST 
109#define MOD_CLKB ADJ_TICK 
110#define MOD_CLKA ADJ_OFFSET_SINGLESHOT /* 0x8000 in original */ 
111#define MOD_TAI ADJ_TAI 
112#define MOD_MICRO ADJ_MICRO 
113#define MOD_NANO ADJ_NANO 
114 
115 
116/* Status codes (timex.status) */ 
117#define STA_PLL 0x0001 /* enable PLL updates (rw) */ 
118#define STA_PPSFREQ 0x0002 /* enable PPS freq discipline (rw) */ 
119#define STA_PPSTIME 0x0004 /* enable PPS time discipline (rw) */ 
120#define STA_FLL 0x0008 /* select frequency-lock mode (rw) */ 
121 
122#define STA_INS 0x0010 /* insert leap (rw) */ 
123#define STA_DEL 0x0020 /* delete leap (rw) */ 
124#define STA_UNSYNC 0x0040 /* clock unsynchronized (rw) */ 
125#define STA_FREQHOLD 0x0080 /* hold frequency (rw) */ 
126 
127#define STA_PPSSIGNAL 0x0100 /* PPS signal present (ro) */ 
128#define STA_PPSJITTER 0x0200 /* PPS signal jitter exceeded (ro) */ 
129#define STA_PPSWANDER 0x0400 /* PPS signal wander exceeded (ro) */ 
130#define STA_PPSERROR 0x0800 /* PPS signal calibration error (ro) */ 
131 
132#define STA_CLOCKERR 0x1000 /* clock hardware fault (ro) */ 
133#define STA_NANO 0x2000 /* resolution (0 = us, 1 = ns) (ro) */ 
134#define STA_MODE 0x4000 /* mode (0 = PLL, 1 = FLL) (ro) */ 
135#define STA_CLK 0x8000 /* clock source (0 = A, 1 = B) (ro) */ 
136 
137/* Read-only bits */ 
138#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER \ 
139 | STA_PPSERROR | STA_CLOCKERR | STA_NANO | STA_MODE | STA_CLK) 
140 
141#endif /* bits/timex.h */ 
142