[RFC,28/52] Y2038: add function __time_t64
Commit Message
These implementations use only 32-bit time kernel syscalls.
Therefore, stime() will always set errno to EOVERFLOW and return -1 for dates beyond Y2038.
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
sysdeps/posix/time.c | 26 ++++++++++++++++++++++++++
sysdeps/unix/sysv/linux/time.c | 22 ++++++++++++++++++++++
time/Versions | 1 +
time/time.c | 13 +++++++++++++
4 files changed, 62 insertions(+)
@@ -38,3 +38,29 @@ time (time_t *t)
return result;
}
libc_hidden_def (time)
+
+/* 64-bit time version */
+
+extern int __y2038_linux_support;
+
+__time64_t
+__time_t64 (__time64_t *t)
+{
+ struct timeval tv32;
+ __time64_t result;
+
+ if (__y2038_linux_support)
+ {
+ /* TODO: implement using 64-bit time syscall */
+ }
+
+ if (__gettimeofday (&tv32, (struct timezone *) NULL))
+ result = (__time64_t) -1;
+ else
+ result = (__time64_t) tv32.tv_sec;
+
+ if (t != NULL)
+ *t = result;
+
+ return result;
+}
@@ -34,6 +34,28 @@ time (time_t *t)
}
libc_hidden_def (time)
+/* 64-BIT TIME VERSION */
+
+extern int __y2038_linux_support;
+
+__time64_t
+__time_t64 (__time64_t *t)
+{
+ INTERNAL_SYSCALL_DECL (err);
+ __time64_t res;
+
+ if (__y2038_linux_support)
+ {
+ /* TODO: implement using 64-bit time syscall */
+ }
+
+ res = INTERNAL_SYSCALL (time, err, 1, NULL);
+ /* There cannot be any error. */
+ if (t != NULL)
+ *t = res;
+ return res;
+}
+
#else
# include <sysdeps/posix/time.c>
@@ -71,5 +71,6 @@ libc {
GLIBC_Y2038 {
__timespec_get64;
+ __time_t64;
}
}
@@ -31,3 +31,16 @@ time (time_t *timer)
libc_hidden_def (time)
stub_warning (time)
+
+/* 64-bit time version */
+
+__time64_t
+__time_t64 (__time64_ *timer)
+{
+ __set_errno (ENOSYS);
+
+ if (timer != NULL)
+ *timer = (__time64_t) -1;
+ return (__time64_t) -1;
+}
+libc_hidden_def (__time_t64)