summaryrefslogtreecommitdiff
path: root/time/localtime.c
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-06-18 21:14:43 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-10-10 00:21:43 +0200
commit7d82403ed8b6361e362ee8fbf4c3b316e26268dc (patch)
tree54a0d6c8fcf4d75f7fb4303a1fdd948cc3c8b34c /time/localtime.c
parent6ccd9dd89364bccd3f9774be68232908bdbda8b9 (diff)
downloadglibc-aaribaud/make-check.tar.gz
Y2038: make __tz_convert compatible with 64-bit-timeaaribaud/make-check
Now that __time_64_t exists, we can switch internal function __tz_convert from 32-bit to 64-bit time. This involves switching some other internal functions and turning some implementations which use these into wrappers between public 32-bit and internal 64-bit time. * __tz_compute: Pass timer as a __time64_t rather than time_t. * __offtime: Pass __timer as a __time64_t value rather than a const time_t pointer. * __tz_convert: Likewise. * localtime: provide a 64-bit time version and make the 32-bit time version a wrapper of it. * localtime_r: Likewise. * ctime: Likewise. * ctime_r: Likewise. * gmtime: Likewise. * gmtime_r: Likewise.
Diffstat (limited to 'time/localtime.c')
-rw-r--r--time/localtime.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/time/localtime.c b/time/localtime.c
index 8684a8a971..8e3b76e6cb 100644
--- a/time/localtime.c
+++ b/time/localtime.c
@@ -21,21 +21,50 @@
/* The C Standard says that localtime and gmtime return the same pointer. */
struct tm _tmbuf;
-
/* Return the `struct tm' representation of *T in local time,
using *TP to store the result. */
struct tm *
+__localtime64_r (const __time64_t *t, struct tm *tp)
+{
+ return __tz_convert (*t, 1, tp);
+}
+
+/* Provide a 32-bit wrapper if needed */
+
+#if __TIMESIZE != 64
+
+struct tm *
__localtime_r (const time_t *t, struct tm *tp)
{
- return __tz_convert (t, 1, tp);
+ __time64_t t64 = *t;
+ return __localtime64_r (&t64, tp);
}
-weak_alias (__localtime_r, localtime_r)
+#endif
+
+/* This always works because either __TIMESIZE != 64 and __localtime_r
+ exists or __TIMESIZE == 64 and the definition of __localtime64_r above
+ actually defined __localtime_r. */
+weak_alias (__localtime_r, localtime_r)
/* Return the `struct tm' representation of *T in local time. */
struct tm *
+__localtime64 (const __time64_t *t)
+{
+ return __tz_convert (*t, 1, &_tmbuf);
+}
+libc_hidden_def (__localtime64)
+
+/* Provide a 32-bit wrapper if needed */
+
+#if __TIMESIZE != 64
+
+struct tm *
localtime (const time_t *t)
{
- return __tz_convert (t, 1, &_tmbuf);
+ __time64_t t64 = *t;
+ return __localtime64 (&t64);
}
libc_hidden_def (localtime)
+
+#endif