alpha: Remove __ASSUME_32BITUIDS.
[glibc-ports.git] / sysdeps / unix / sysv / linux / alpha / adjtime.c
blobce1d220c37db16681b3e055eb1e3058694ec999c
1 /* Copyright (C) 1998,2000,2002,2003,2004,2006 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
18 #include <shlib-compat.h>
19 #include <sysdep.h>
20 #include <sys/time.h>
21 #include <kernel-features.h>
23 #if !defined __ASSUME_TIMEVAL64 || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
24 struct timeval32
26 int tv_sec, tv_usec;
29 struct 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)
41 struct timeval32 time; /* (read only) */
42 long tick; /* (modified) usecs between clock ticks */
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) */
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;
58 #define TIMEVAL timeval32
59 #define TIMEX timex32
60 #define ADJTIME attribute_compat_text_section __adjtime_tv32
61 #define ADJTIMEX(x) INLINE_SYSCALL (old_adjtimex, 1, x)
62 #define ADJTIMEX32(x) INLINE_SYSCALL (old_adjtimex, 1, x)
63 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
64 #define LINKAGE
65 #else
66 #define LINKAGE static
67 #endif
69 LINKAGE int ADJTIME (const struct TIMEVAL *itv, struct TIMEVAL *otv);
71 #include <sysdeps/unix/sysv/linux/adjtime.c>
73 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
74 int
75 attribute_compat_text_section
76 __adjtimex_tv32 (struct timex32 *tx) { return ADJTIMEX (tx); }
77 strong_alias (__adjtimex_tv32, __adjtimex_tv32_1);
78 strong_alias (__adjtimex_tv32, __adjtimex_tv32_2);
79 compat_symbol (libc, __adjtimex_tv32_1, __adjtimex, GLIBC_2_0);
80 compat_symbol (libc, __adjtimex_tv32_2, adjtimex, GLIBC_2_0);
81 compat_symbol (libc, __adjtime_tv32, adjtime, GLIBC_2_0);
82 #endif
83 #endif /* !__ASSUME_TIMEVAL64 || SHLIB_COMPAT */
85 #undef TIMEVAL
86 #define TIMEVAL timeval
87 #undef TIMEX
88 #define TIMEX timex
89 #undef ADJTIMEX
90 #define ADJTIMEX(x) INLINE_SYSCALL (adjtimex, 1, x)
92 #undef LINKAGE
93 #undef ADJTIME
94 #if !defined __ASSUME_TIMEVAL64
95 #define LINKAGE static
96 #define ADJTIME __adjtime_tv64
97 #endif
99 #include <sysdeps/unix/sysv/linux/adjtime.c>
100 #include <stdbool.h>
102 #if !defined __ASSUME_TIMEVAL64
103 static bool missing_adjtimex;
106 __adjtime (itv, otv)
107 const struct timeval *itv;
108 struct timeval *otv;
110 struct timeval32 itv32, otv32;
111 int ret;
113 switch (missing_adjtimex)
115 case false:
116 ret = __adjtime_tv64 (itv, otv);
117 if (ret && errno == ENOSYS)
118 missing_adjtimex = 1;
119 else
120 break;
122 /* FALLTHRU */
124 default:
125 itv32.tv_sec = itv->tv_sec;
126 itv32.tv_usec = itv->tv_usec;
127 ret = __adjtime_tv32 (&itv32, &otv32);
128 if (ret == 0)
130 otv->tv_sec = otv32.tv_sec;
131 otv->tv_usec = otv32.tv_usec;
133 break;
136 return ret;
138 #endif
140 versioned_symbol (libc, __adjtime, adjtime, GLIBC_2_1);
143 __adjtimex_tv64 (struct timex *tx)
145 #if defined __ASSUME_TIMEVAL64
146 return ADJTIMEX (tx);
147 #else
148 struct timex32 tx32;
149 int ret;
151 switch (missing_adjtimex)
153 case false:
154 ret = ADJTIMEX (tx);
155 if (ret && errno == ENOSYS)
156 missing_adjtimex = 1;
157 else
158 break;
160 /* FALLTHRU */
162 default:
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;
184 ret = ADJTIMEX32 (&tx32);
185 if (ret == 0)
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;
208 break;
211 return ret;
212 #endif
215 strong_alias (__adjtimex_tv64, __adjtimex_internal);
216 strong_alias (__adjtimex_tv64, __adjtimex_tv64p);
217 weak_alias (__adjtimex_tv64, ntp_adjtime);
218 versioned_symbol (libc, __adjtimex_tv64, __adjtimex, GLIBC_2_1);
219 versioned_symbol (libc, __adjtimex_tv64p, adjtimex, GLIBC_2_1);