Update syscall lists for Linux 5.11.
[glibc.git] / sysdeps / unix / sysv / linux / clock_adjtime.c
blob7850eb2ec42ac5f7de8a8914c7dcd0dd3172e6d9
1 /* clock_adjtime -- tune kernel clock.
2 Copyright (C) 2020-2021 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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 License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
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.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, see <https://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <stdlib.h>
21 #include <time.h>
22 #include <sysdep.h>
23 #include <sys/timex.h>
24 #include <kernel-features.h>
26 int
27 __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64)
29 #ifndef __NR_clock_adjtime64
30 # define __NR_clock_adjtime64 __NR_clock_adjtime
31 #endif
32 int r = INLINE_SYSCALL_CALL (clock_adjtime64, clock_id, tx64);
33 #ifndef __ASSUME_TIME64_SYSCALLS
34 if (r >= 0 || errno != ENOSYS)
35 return r;
37 if (tx64->modes & ADJ_SETOFFSET
38 && ! in_time_t_range (tx64->time.tv_sec))
40 __set_errno (EOVERFLOW);
41 return -1;
44 struct timex tx32 = valid_timex64_to_timex (*tx64);
45 r = INLINE_SYSCALL_CALL (clock_adjtime, clock_id, &tx32);
46 if (r >= 0)
47 *tx64 = valid_timex_to_timex64 (tx32);
48 #endif
49 return r;
52 #if __TIMESIZE != 64
53 libc_hidden_def (__clock_adjtime64)
55 int
56 __clock_adjtime (const clockid_t clock_id, struct timex *tx)
58 struct __timex64 tx64;
59 int retval;
61 tx64 = valid_timex_to_timex64 (*tx);
62 retval = __clock_adjtime64 (clock_id, &tx64);
63 if (retval >= 0)
64 *tx = valid_timex64_to_timex (tx64);
66 return retval;
68 #endif
69 libc_hidden_def (__clock_adjtime);
70 strong_alias (__clock_adjtime, clock_adjtime)