Update syscall lists for Linux 5.11.
[glibc.git] / sysdeps / unix / sysv / linux / settimeofday.c
bloba9dc556d8d9672b58b85291a4994b18fd84f9258
1 /* settimeofday -- set system time - Linux version supporting 64 bit time.
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
7 License as published by the Free Software Foundation; either
8 version 2.1 of the 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; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <time.h>
21 #include <sys/time.h>
23 /* Set the current time of day and timezone information.
24 This call is restricted to the super-user. */
25 int
26 __settimeofday64 (const struct __timeval64 *tv, const struct timezone *tz)
28 /* Backwards compatibility for setting the UTC offset. */
29 if (__glibc_unlikely (tz != 0))
31 if (tv != 0)
33 __set_errno (EINVAL);
34 return -1;
36 return __settimezone (tz);
39 struct __timespec64 ts = timeval64_to_timespec64 (*tv);
40 return __clock_settime64 (CLOCK_REALTIME, &ts);
43 #if __TIMESIZE != 64
44 libc_hidden_def (__settimeofday64)
46 int
47 __settimeofday (const struct timeval *tv, const struct timezone *tz)
49 if (__glibc_unlikely (tv == NULL))
50 return __settimeofday64 (NULL, tz);
51 else
53 struct __timeval64 tv64 = valid_timeval_to_timeval64 (*tv);
54 return __settimeofday64 (&tv64, tz);
57 #endif
58 weak_alias (__settimeofday, settimeofday);