@@ -24,8 +24,7 @@ extern int __gettimeofday (struct timeval *__tv,
struct timezone *__tz);
libc_hidden_proto (__gettimeofday)
libc_hidden_proto (gettimeofday)
-extern int __settimeofday (const struct timeval *__tv,
- const struct timezone *__tz)
+extern int __settimezone (const struct timezone *__tz)
attribute_hidden;
extern int __adjtime (const struct timeval *__delta,
struct timeval *__olddelta);
@@ -76,7 +76,6 @@ setreuid - setreuid i:ii __setreuid setreuid
setrlimit - setrlimit i:ip __setrlimit setrlimit
setsid - setsid i: __setsid setsid
setsockopt - setsockopt i:iiibn setsockopt __setsockopt
-settimeofday - settimeofday i:PP __settimeofday settimeofday
setuid - setuid i:i __setuid setuid
shutdown - shutdown i:ii shutdown
sigaction - sigaction i:ipp __sigaction sigaction
new file mode 100644
@@ -0,0 +1,55 @@
+/* settimeofday -- Set the current time of day. Linux/Alpha/tv32 version.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <time.h>
+#include <sys/time.h>
+#include <shlib-compat.h>
+
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+
+struct timeval32
+{
+ int tv_sec, tv_usec;
+};
+
+/* Set the current time of day and timezone information.
+ This call is restricted to the super-user. */
+int
+attribute_compat_text_section
+__settimeofday_tv32 (const struct timeval32 *tv32,
+ const struct timezone *tz)
+{
+ if (__glibc_unlikely (tz != 0))
+ {
+ if (tv32 != 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __settimezone (tz);
+ }
+
+ struct timespec ts;
+ ts.tv_sec = tv32->tv_sec;
+ ts.tv_nsec = tv32->tv_usec * 1000;
+ return __clock_settime (CLOCK_REALTIME, &ts);
+}
+
+compat_symbol (libc, __settimeofday_tv32, settimeofday, GLIBC_2_0);
+#endif
new file mode 100644
@@ -0,0 +1,22 @@
+/* settimeofday -- Set the current time of day. Linux/Alpha/tv64 version.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+/* We can use the generic implementation, but we have to override its
+ default symbol version. */
+#define VERSION_settimeofday GLIBC_2.1
+#include <time/settimeofday.c>
@@ -24,7 +24,6 @@ pciconfig_iobase EXTRA pciconfig_iobase 3 __pciconfig_iobase pciconfig_iobase
# support old timeval32 entry points
osf_gettimeofday - osf_gettimeofday 2 __gettimeofday_tv32 __gettimeofday@GLIBC_2.0 gettimeofday@GLIBC_2.0
-osf_settimeofday - osf_settimeofday 2 __settimeofday_tv32 settimeofday@GLIBC_2.0
osf_getitimer - osf_getitimer 2 __getitimer_tv32 getitimer@GLIBC_2.0
osf_setitimer - osf_setitimer 3 __setitimer_tv32 setitimer@GLIBC_2.0
osf_utimes - osf_utimes 2 __utimes_tv32 utimes@GLIBC_2.0
@@ -33,7 +32,6 @@ osf_wait4 - osf_wait4 4 __wait4_tv32 wait4@GLIBC_2.0
# support new timeval64 entry points
gettimeofday - gettimeofday 2 __GI___gettimeofday gettimeofday@@GLIBC_2.1 __gettimeofday@@GLIBC_2.1
-settimeofday - settimeofday 2 __settimeofday settimeofday@@GLIBC_2.1
getitimer - getitimer 2 __getitimer getitimer@@GLIBC_2.1
setitimer - setitimer 3 __setitimer setitimer@@GLIBC_2.1
utimes - utimes 2 __utimes utimes@@GLIBC_2.1
new file mode 100644
@@ -0,0 +1,39 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <sys/time.h>
+#include <sysdep.h>
+
+/* Set the system-wide timezone.
+ This call is restricted to the super-user.
+ This operation is considered obsolete, kernel support may not be
+ available on all architectures. */
+
+#ifdef __NR_settimeofday
+
+int
+__settimezone (const struct timezone *tz)
+{
+ return INLINE_SYSCALL_CALL (settimeofday, NULL, tz);
+}
+
+#else
+
+#include <time/settimezone.c>
+
+#endif
@@ -36,7 +36,7 @@ routines := offtime asctime clock ctime ctime_r difftime \
stime dysize timegm ftime \
getdate strptime strptime_l \
strftime wcsftime strftime_l wcsftime_l \
- timespec_get
+ timespec_get settimezone
aux := era alt_digit lc-time-cleanup
tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
/* Set the current time of day and timezone information.
@@ -23,9 +24,24 @@
int
__settimeofday (const struct timeval *tv, const struct timezone *tz)
{
- __set_errno (ENOSYS);
- return -1;
+ if (__glibc_unlikely (tz != 0))
+ {
+ if (tv != 0)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+ return __settimezone (tz);
+ }
+
+ struct timespec ts;
+ TIMEVAL_TO_TIMESPEC (tv, &ts);
+ return __clock_settime (CLOCK_REALTIME, &ts);
}
-stub_warning (settimeofday)
-weak_alias (__settimeofday, settimeofday)
+#ifdef VERSION_settimeofday
+weak_alias (__settimeofday, __settimeofday_w);
+default_symbol_version (__settimeofday_w, settimeofday, VERSION_settimeofday);
+#else
+weak_alias (__settimeofday, settimeofday);
+#endif
new file mode 100644
@@ -0,0 +1,28 @@
+/* Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <sys/time.h>
+
+/* Set the system-wide timezone.
+ This call is restricted to the super-user. */
+int
+__settimezone (const struct timezone *tz)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}