]> git.ipfire.org Git - thirdparty/glibc.git/blame - sysdeps/unix/sysv/linux/alpha/adjtime.c
Replace FSF snail mail address by URL.
[thirdparty/glibc.git] / sysdeps / unix / sysv / linux / alpha / adjtime.c
CommitLineData
44422d11 1/* Copyright (C) 1998,2000,2002,2003,2004,2006 Free Software Foundation, Inc.
d958c121
UD
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
3214b89b
AJ
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.
d958c121
UD
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
3214b89b 12 Lesser General Public License for more details.
d958c121 13
3214b89b 14 You should have received a copy of the GNU Lesser General Public
ab84e3ff
PE
15 License along with the GNU C Library. If not, see
16 <http://www.gnu.org/licenses/>. */
d958c121 17
0772663d 18#include <shlib-compat.h>
ebcd2cd1
RH
19#include <sysdep.h>
20#include <sys/time.h>
44422d11 21#include <kernel-features.h>
0772663d 22
ebcd2cd1 23#if !defined __ASSUME_TIMEVAL64 || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
d958c121
UD
24struct timeval32
25{
26 int tv_sec, tv_usec;
27};
28
29struct timex32 {
30 unsigned int modes; /* mode selector */
31 long offset; /* time offset (usec) */
32 long freq; /* frequency offset (scaled ppm) */
33 long maxerror; /* maximum error (usec) */
34 long esterror; /* estimated error (usec) */
35 int status; /* clock command/status */
36 long constant; /* pll time constant */
37 long precision; /* clock precision (usec) (read only) */
38 long tolerance; /* clock frequency tolerance (ppm)
39 * (read only)
40 */
41 struct timeval32 time; /* (read only) */
42 long tick; /* (modified) usecs between clock ticks */
43
44 long ppsfreq; /* pps frequency (scaled ppm) (ro) */
45 long jitter; /* pps jitter (us) (ro) */
46 int shift; /* interval duration (s) (shift) (ro) */
47 long stabil; /* pps stability (scaled ppm) (ro) */
48 long jitcnt; /* jitter limit exceeded (ro) */
49 long calcnt; /* calibration intervals (ro) */
50 long errcnt; /* calibration errors (ro) */
51 long stbcnt; /* stability limit exceeded (ro) */
52
53 int :32; int :32; int :32; int :32;
54 int :32; int :32; int :32; int :32;
55 int :32; int :32; int :32; int :32;
56};
57
58#define TIMEVAL timeval32
59#define TIMEX timex32
36727f22 60#define ADJTIME attribute_compat_text_section __adjtime_tv32
ebcd2cd1 61#define ADJTIMEX(x) INLINE_SYSCALL (old_adjtimex, 1, x)
cfbf1a2f 62#define ADJTIMEX32(x) INLINE_SYSCALL (old_adjtimex, 1, x)
0772663d 63#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
d958c121
UD
64#define LINKAGE
65#else
66#define LINKAGE static
67#endif
68
69LINKAGE int ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv);
d958c121
UD
70
71#include <sysdeps/unix/sysv/linux/adjtime.c>
72
0772663d 73#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
36727f22
UD
74int
75attribute_compat_text_section
76__adjtimex_tv32 (struct timex32 *tx) { return ADJTIMEX (tx); }
ebcd2cd1
RH
77strong_alias (__adjtimex_tv32, __adjtimex_tv32_1);
78strong_alias (__adjtimex_tv32, __adjtimex_tv32_2);
79compat_symbol (libc, __adjtimex_tv32_1, __adjtimex, GLIBC_2_0);
80compat_symbol (libc, __adjtimex_tv32_2, adjtimex, GLIBC_2_0);
4a88ca46 81compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0);
d958c121 82#endif
ebcd2cd1 83#endif /* !__ASSUME_TIMEVAL64 || SHLIB_COMPAT */
d958c121
UD
84
85#undef TIMEVAL
86#define TIMEVAL timeval
87#undef TIMEX
88#define TIMEX timex
d958c121 89#undef ADJTIMEX
ebcd2cd1 90#define ADJTIMEX(x) INLINE_SYSCALL (adjtimex, 1, x)
36f86ab9 91
d958c121 92#undef LINKAGE
36f86ab9
RH
93#undef ADJTIME
94#if !defined __ASSUME_TIMEVAL64
d958c121 95#define LINKAGE static
36f86ab9
RH
96#define ADJTIME __adjtime_tv64
97#endif
d958c121
UD
98
99#include <sysdeps/unix/sysv/linux/adjtime.c>
ebcd2cd1
RH
100#include <stdbool.h>
101
102#if !defined __ASSUME_TIMEVAL64
103static bool missing_adjtimex;
d958c121
UD
104
105int
106__adjtime (itv, otv)
107 const struct timeval *itv;
108 struct timeval *otv;
109{
ebcd2cd1 110 struct timeval32 itv32, otv32;
d958c121
UD
111 int ret;
112
ebcd2cd1 113 switch (missing_adjtimex)
d958c121 114 {
ebcd2cd1 115 case false:
d958c121
UD
116 ret = __adjtime_tv64 (itv, otv);
117 if (ret && errno == ENOSYS)
118 missing_adjtimex = 1;
ebcd2cd1
RH
119 else
120 break;
d958c121 121
ebcd2cd1 122 /* FALLTHRU */
d958c121 123
ebcd2cd1 124 default:
d958c121
UD
125 itv32.tv_sec = itv->tv_sec;
126 itv32.tv_usec = itv->tv_usec;
127 ret = __adjtime_tv32 (&itv32, &otv32);
128 if (ret == 0)
129 {
130 otv->tv_sec = otv32.tv_sec;
131 otv->tv_usec = otv32.tv_usec;
132 }
ebcd2cd1 133 break;
d958c121
UD
134 }
135
136 return ret;
137}
ebcd2cd1 138#endif
d958c121 139
0772663d 140versioned_symbol (libc, __adjtime, adjtime, GLIBC_2_1);
d958c121 141
d958c121 142int
9ba8164e 143__adjtimex_tv64 (struct timex *tx)
d958c121 144{
ebcd2cd1
RH
145#if defined __ASSUME_TIMEVAL64
146 return ADJTIMEX (tx);
147#else
148 struct timex32 tx32;
d958c121
UD
149 int ret;
150
ebcd2cd1
RH
151 switch (missing_adjtimex)
152 {
153 case false:
154 ret = ADJTIMEX (tx);
155 if (ret && errno == ENOSYS)
d958c121 156 missing_adjtimex = 1;
ebcd2cd1
RH
157 else
158 break;
d958c121 159
ebcd2cd1 160 /* FALLTHRU */
d958c121 161
ebcd2cd1 162 default:
d958c121
UD
163 tx32.modes = tx->modes;
164 tx32.offset = tx->offset;
165 tx32.freq = tx->freq;
166 tx32.maxerror = tx->maxerror;
167 tx32.esterror = tx->esterror;
168 tx32.status = tx->status;
169 tx32.constant = tx->constant;
170 tx32.precision = tx->precision;
171 tx32.tolerance = tx->tolerance;
172 tx32.time.tv_sec = tx->time.tv_sec;
173 tx32.time.tv_sec = tx->time.tv_usec;
174 tx32.tick = tx->tick;
175 tx32.ppsfreq = tx->ppsfreq;
176 tx32.jitter = tx->jitter;
177 tx32.shift = tx->shift;
178 tx32.stabil = tx->stabil;
179 tx32.jitcnt = tx->jitcnt;
180 tx32.calcnt = tx->calcnt;
181 tx32.errcnt = tx->errcnt;
182 tx32.stbcnt = tx->stbcnt;
183
cfbf1a2f 184 ret = ADJTIMEX32 (&tx32);
d958c121
UD
185 if (ret == 0)
186 {
187 tx->modes = tx32.modes;
188 tx->offset = tx32.offset;
189 tx->freq = tx32.freq;
190 tx->maxerror = tx32.maxerror;
191 tx->esterror = tx32.esterror;
192 tx->status = tx32.status;
193 tx->constant = tx32.constant;
194 tx->precision = tx32.precision;
195 tx->tolerance = tx32.tolerance;
196 tx->time.tv_sec = tx32.time.tv_sec;
197 tx->time.tv_usec = tx32.time.tv_sec;
198 tx->tick = tx32.tick;
199 tx->ppsfreq = tx32.ppsfreq;
200 tx->jitter = tx32.jitter;
201 tx->shift = tx32.shift;
202 tx->stabil = tx32.stabil;
203 tx->jitcnt = tx32.jitcnt;
204 tx->calcnt = tx32.calcnt;
205 tx->errcnt = tx32.errcnt;
206 tx->stbcnt = tx32.stbcnt;
207 }
ebcd2cd1 208 break;
d958c121
UD
209 }
210
211 return ret;
ebcd2cd1 212#endif
d958c121
UD
213}
214
4def79b5 215strong_alias (__adjtimex_tv64, __adjtimex_internal);
d958c121 216strong_alias (__adjtimex_tv64, __adjtimex_tv64p);
b8cce412 217weak_alias (__adjtimex_tv64, ntp_adjtime);
0772663d
UD
218versioned_symbol (libc, __adjtimex_tv64, __adjtimex, GLIBC_2_1);
219versioned_symbol (libc, __adjtimex_tv64p, adjtimex, GLIBC_2_1);