This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC PATCH 32/52] Y2038: add function __settimeofday_t64
Implementing a 64-bit settimeofday requires adding a new
file to build under time/ and we cannot name that new file
'settimeofday.c' or it will break the 32-bit settimeofday
symbol, so we call it 'settimeofday64.c'.
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
sysdeps/unix/sysv/linux/settimeofday64.c | 44 ++++++++++++++++++++++++++++++++
time/Makefile | 3 ++-
time/Versions | 1 +
time/settimeofday.c | 8 ++++++
4 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 sysdeps/unix/sysv/linux/settimeofday64.c
diff --git a/sysdeps/unix/sysv/linux/settimeofday64.c b/sysdeps/unix/sysv/linux/settimeofday64.c
new file mode 100644
index 0000000000..7aaef1c613
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/settimeofday64.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991-2017 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 <sysdep.h>
+#include <errno.h>
+#include <sys/time.h>
+
+extern int __y2038_linux_support;
+
+int __settimeofday_t64(const struct __timeval64 *tv,
+ const struct timezone *tz)
+{
+ struct timeval tv32;
+
+ if (__y2038_linux_support)
+ {
+ /* TODO: use 64-bit syscall */
+ }
+
+ if (tv && tv->tv_sec > INT_MAX)
+ {
+ __set_errno(EOVERFLOW);
+ return -1;
+ }
+
+ tv32.tv_sec = tv->tv_sec;
+ tv32.tv_usec = tv->tv_usec;
+
+ return settimeofday(&tv32, tz);
+}
diff --git a/time/Makefile b/time/Makefile
index 317c4d8901..5fb26f6dbf 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -36,7 +36,8 @@ 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 \
+ settimeofday64
aux := era alt_digit lc-time-cleanup
tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
diff --git a/time/Versions b/time/Versions
index 7daf158a8b..d420770af3 100644
--- a/time/Versions
+++ b/time/Versions
@@ -74,5 +74,6 @@ libc {
__time_t64;
__stime_t64;
__gettimeofday_t64;
+ __settimeofday_t64;
}
}
diff --git a/time/settimeofday.c b/time/settimeofday.c
index 317c93d35f..65db5ab6e5 100644
--- a/time/settimeofday.c
+++ b/time/settimeofday.c
@@ -29,3 +29,11 @@ __settimeofday (const struct timeval *tv, const struct timezone *tz)
stub_warning (settimeofday)
weak_alias (__settimeofday, settimeofday)
+
+int
+__settimeofday_t64 (const struct timeval *tv, const struct timezone *tz)
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+stub_warning (__settimeofday_t64)
--
2.11.0