]>
Commit | Line | Data |
---|---|---|
620f462e | 1 | /* Internal declarations for sys/timex.h. |
dff8da6b | 2 | Copyright (C) 2014-2024 Free Software Foundation, Inc. |
620f462e JM |
3 | This file is part of the GNU C Library. |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Lesser General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with the GNU C Library; if not, see | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
620f462e JM |
18 | |
19 | #ifndef _INCLUDE_SYS_TIMEX_H | |
20 | #define _INCLUDE_SYS_TIMEX_H 1 | |
21 | ||
22 | #include_next <sys/timex.h> | |
23 | ||
47755784 ZW |
24 | # ifndef _ISOMAC |
25 | ||
d62a70fd | 26 | extern int __adjtimex (struct timex *__ntx) __nonnull ((1)); |
620f462e JM |
27 | libc_hidden_proto (__adjtimex) |
28 | ||
898f3793 | 29 | # include <time.h> |
dbf8178f LM |
30 | # include <struct___timeval64.h> |
31 | /* Local definition of 64 bit time supporting timex struct */ | |
32 | # if __TIMESIZE == 64 | |
33 | # define __timex64 timex | |
63ff4a6d | 34 | # define __clock_adjtime64 __clock_adjtime |
8f8a6cae | 35 | # define ___adjtimex64 ___adjtimex |
df428950 | 36 | # define __ntptimeval64 ntptimeval |
5613afe9 | 37 | # define __ntp_gettime64 __ntp_gettime |
4c4fc048 | 38 | # define __ntp_gettimex64 __ntp_gettimex |
dbf8178f LM |
39 | # else |
40 | ||
41 | struct __timex64 | |
42 | { | |
43 | unsigned int modes; /* mode selector */ | |
44 | int :32; /* pad */ | |
45 | long long int offset; /* time offset (usec) */ | |
46 | long long int freq; /* frequency offset (scaled ppm) */ | |
47 | long long int maxerror; /* maximum error (usec) */ | |
48 | long long int esterror; /* estimated error (usec) */ | |
49 | int status; /* clock command/status */ | |
50 | int :32; /* pad */ | |
51 | long long int constant; /* pll time constant */ | |
52 | long long int precision; /* clock precision (usec) (read only) */ | |
53 | long long int tolerance; /* clock frequency tolerance (ppm) (ro) */ | |
54 | struct __timeval64 time; /* (read only, except for ADJ_SETOFFSET) */ | |
55 | long long int tick; /* (modified) usecs between clock ticks */ | |
56 | long long int ppsfreq; /* pps frequency (scaled ppm) (ro) */ | |
57 | long long int jitter; /* pps jitter (us) (ro) */ | |
58 | int shift; /* interval duration (s) (shift) (ro) */ | |
59 | int :32; /* pad */ | |
60 | long long int stabil; /* pps stability (scaled ppm) (ro) */ | |
61 | long long int jitcnt; /* jitter limit exceeded (ro) */ | |
62 | long long int calcnt; /* calibration intervals (ro) */ | |
63 | long long int errcnt; /* calibration errors (ro) */ | |
64 | long long int stbcnt; /* stability limit exceeded (ro) */ | |
65 | ||
66 | int tai; /* TAI offset (ro) */ | |
67 | ||
68 | int :32; | |
69 | int :32; | |
70 | int :32; | |
71 | int :32; | |
72 | int :32; | |
73 | int :32; | |
74 | int :32; | |
75 | int :32; | |
76 | int :32; | |
77 | int :32; | |
78 | int :32; | |
79 | }; | |
ed2ddeff | 80 | extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2)); |
63ff4a6d | 81 | libc_hidden_proto (__clock_adjtime64); |
d62a70fd | 82 | extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1)); |
8f8a6cae | 83 | libc_hidden_proto (___adjtimex64) |
df428950 LM |
84 | |
85 | struct __ntptimeval64 | |
86 | { | |
87 | struct __timeval64 time; /* current time (ro) */ | |
88 | long int maxerror; /* maximum error (us) (ro) */ | |
89 | long int esterror; /* estimated error (us) (ro) */ | |
90 | long int tai; /* TAI offset (ro) */ | |
91 | ||
92 | long int __glibc_reserved1; | |
93 | long int __glibc_reserved2; | |
94 | long int __glibc_reserved3; | |
95 | long int __glibc_reserved4; | |
96 | }; | |
6a9786b8 | 97 | extern int __ntp_gettime64 (struct __ntptimeval64 *ntv) __nonnull ((1)); |
5613afe9 | 98 | libc_hidden_proto (__ntp_gettime64) |
6a9786b8 | 99 | extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv) __nonnull ((1)); |
4c4fc048 | 100 | libc_hidden_proto (__ntp_gettimex64) |
5613afe9 | 101 | |
dbf8178f | 102 | # endif |
898f3793 LM |
103 | |
104 | /* Convert a known valid struct timex into a struct __timex64. */ | |
105 | static inline struct __timex64 | |
106 | valid_timex_to_timex64 (const struct timex tx) | |
107 | { | |
108 | struct __timex64 tx64; | |
109 | ||
110 | tx64.modes = tx.modes; | |
111 | tx64.offset = tx.offset; | |
112 | tx64.freq = tx.freq; | |
113 | tx64.maxerror = tx.maxerror; | |
114 | tx64.esterror = tx.esterror; | |
115 | tx64.status = tx.status; | |
116 | tx64.constant = tx.constant; | |
117 | tx64.precision = tx.precision; | |
118 | tx64.tolerance = tx.tolerance; | |
119 | tx64.time = valid_timeval_to_timeval64 (tx.time); | |
120 | tx64.tick = tx.tick; | |
121 | tx64.ppsfreq = tx.ppsfreq; | |
122 | tx64.jitter = tx.jitter; | |
123 | tx64.shift = tx.shift; | |
124 | tx64.stabil = tx.stabil; | |
125 | tx64.jitcnt = tx.jitcnt; | |
126 | tx64.calcnt = tx.calcnt; | |
127 | tx64.errcnt = tx.errcnt; | |
128 | tx64.stbcnt = tx.stbcnt; | |
129 | tx64.tai = tx.tai; | |
130 | ||
131 | return tx64; | |
132 | } | |
133 | ||
134 | /* Convert a known valid struct __timex64 into a struct timex. */ | |
135 | static inline struct timex | |
136 | valid_timex64_to_timex (const struct __timex64 tx64) | |
137 | { | |
138 | struct timex tx; | |
139 | ||
140 | tx.modes = tx64.modes; | |
141 | tx.offset = tx64.offset; | |
142 | tx.freq = tx64.freq; | |
143 | tx.maxerror = tx64.maxerror; | |
144 | tx.esterror = tx64.esterror; | |
145 | tx.status = tx64.status; | |
146 | tx.constant = tx64.constant; | |
147 | tx.precision = tx64.precision; | |
148 | tx.tolerance = tx64.tolerance; | |
149 | tx.time = valid_timeval64_to_timeval (tx64.time); | |
150 | tx.tick = tx64.tick; | |
151 | tx.ppsfreq = tx64.ppsfreq; | |
152 | tx.jitter = tx64.jitter; | |
153 | tx.shift = tx64.shift; | |
154 | tx.stabil = tx64.stabil; | |
155 | tx.jitcnt = tx64.jitcnt; | |
156 | tx.calcnt = tx64.calcnt; | |
157 | tx.errcnt = tx64.errcnt; | |
158 | tx.stbcnt = tx64.stbcnt; | |
159 | tx.tai = tx64.tai; | |
160 | ||
161 | return tx; | |
162 | } | |
10ae49d2 LM |
163 | |
164 | /* Convert a known valid struct ntptimeval into a struct __ntptimeval64. */ | |
165 | static inline struct __ntptimeval64 | |
166 | valid_ntptimeval_to_ntptimeval64 (const struct ntptimeval ntv) | |
167 | { | |
168 | struct __ntptimeval64 ntv64; | |
169 | ||
170 | ntv64.time = valid_timeval_to_timeval64 (ntv.time); | |
171 | ntv64.maxerror = ntv.maxerror; | |
172 | ntv64.esterror = ntv.esterror; | |
173 | ntv64.tai = ntv.tai; | |
174 | ntv64.__glibc_reserved1 = 0; | |
175 | ntv64.__glibc_reserved2 = 0; | |
176 | ntv64.__glibc_reserved3 = 0; | |
177 | ntv64.__glibc_reserved4 = 0; | |
178 | ||
179 | return ntv64; | |
180 | } | |
181 | ||
182 | /* Convert a known valid struct __ntptimeval64 into a struct ntptimeval. */ | |
183 | static inline struct ntptimeval | |
184 | valid_ntptimeval64_to_ntptimeval (const struct __ntptimeval64 ntp64) | |
185 | { | |
186 | struct ntptimeval ntp; | |
187 | ||
188 | ntp.time = valid_timeval64_to_timeval (ntp64.time); | |
189 | ntp.maxerror = ntp64.maxerror; | |
190 | ntp.esterror = ntp64.esterror; | |
191 | ntp.tai = ntp64.tai; | |
192 | ntp.__glibc_reserved1 = 0; | |
193 | ntp.__glibc_reserved2 = 0; | |
194 | ntp.__glibc_reserved3 = 0; | |
195 | ntp.__glibc_reserved4 = 0; | |
196 | ||
197 | return ntp; | |
198 | } | |
47755784 | 199 | # endif /* _ISOMAC */ |
620f462e | 200 | #endif /* sys/timex.h */ |