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>
21 #include <kernel-features.h>
23 #if !defined __ASSUME_TIMEVAL64 || SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
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)
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
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)
66 #define LINKAGE static
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)
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
);
83 #endif /* !__ASSUME_TIMEVAL64 || SHLIB_COMPAT */
86 #define TIMEVAL timeval
90 #define ADJTIMEX(x) INLINE_SYSCALL (adjtimex, 1, x)
94 #if !defined __ASSUME_TIMEVAL64
95 #define LINKAGE static
96 #define ADJTIME __adjtime_tv64
99 #include <sysdeps/unix/sysv/linux/adjtime.c>
102 #if !defined __ASSUME_TIMEVAL64
103 static bool missing_adjtimex
;
107 const struct timeval
*itv
;
110 struct timeval32 itv32
, otv32
;
113 switch (missing_adjtimex
)
116 ret
= __adjtime_tv64 (itv
, otv
);
117 if (ret
&& errno
== ENOSYS
)
118 missing_adjtimex
= 1;
125 itv32
.tv_sec
= itv
->tv_sec
;
126 itv32
.tv_usec
= itv
->tv_usec
;
127 ret
= __adjtime_tv32 (&itv32
, &otv32
);
130 otv
->tv_sec
= otv32
.tv_sec
;
131 otv
->tv_usec
= otv32
.tv_usec
;
140 versioned_symbol (libc
, __adjtime
, adjtime
, GLIBC_2_1
);
143 __adjtimex_tv64 (struct timex
*tx
)
145 #if defined __ASSUME_TIMEVAL64
146 return ADJTIMEX (tx
);
151 switch (missing_adjtimex
)
155 if (ret
&& errno
== ENOSYS
)
156 missing_adjtimex
= 1;
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
);
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
;
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
);