summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-06-28 09:10:11 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-07-05 21:11:16 +0200
commit4cbfd9cb0a4196c0920dd3f1bbd64d4ec38e8bde (patch)
tree26c8bcd600953b02c1d316242e36ca98ee543180 /sysdeps
parent883d2525fca68e86b68ca61300c1d18461e4596e (diff)
downloadglibc-4cbfd9cb0a4196c0920dd3f1bbd64d4ec38e8bde.tar.gz
Y2038: implement Y2038-ready time, stime
These implementations use only 32-bit time kernel syscalls. Therefore, stime() will always set errno to EOVERFLOW and return -1 for dates beyond Y2038.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/posix/time.c26
-rw-r--r--sysdeps/unix/stime.c31
-rw-r--r--sysdeps/unix/sysv/linux/time.c22
3 files changed, 79 insertions, 0 deletions
diff --git a/sysdeps/posix/time.c b/sysdeps/posix/time.c
index 32ca177514..a4c4a03c55 100644
--- a/sysdeps/posix/time.c
+++ b/sysdeps/posix/time.c
@@ -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;
+}
diff --git a/sysdeps/unix/stime.c b/sysdeps/unix/stime.c
index 526ba13914..177c9334ef 100644
--- a/sysdeps/unix/stime.c
+++ b/sysdeps/unix/stime.c
@@ -37,3 +37,34 @@ stime (const time_t *when)
tv.tv_usec = 0;
return __settimeofday (&tv, (struct timezone *) 0);
}
+
+/* 64-bit time version */
+
+extern int __y2038_linux_support;
+
+int
+__stime_t64 (const __time64_t *when)
+{
+ struct timeval tv32;
+
+ if (when == NULL)
+ {
+ __set_errno (EINVAL);
+ return -1;
+ }
+
+ if (__y2038_linux_support)
+ {
+ /* TODO: implement 64-bit-time syscall case */
+ }
+
+ if (*when > INT_MAX)
+ {
+ __set_errno (EOVERFLOW);
+ return -1;
+ }
+
+ tv32.tv_sec = *when;
+ tv32.tv_usec = 0;
+ return __settimeofday (&tv32, (struct timezone *) 0);
+}
diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
index 72d4040cbc..475367b2a1 100644
--- a/sysdeps/unix/sysv/linux/time.c
+++ b/sysdeps/unix/sysv/linux/time.c
@@ -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>