This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 6/8] Y2038: add function __ctime64
- From: "Albert ARIBAUD (3ADEV)" <albert dot aribaud at 3adev dot fr>
- To: libc-alpha at sourceware dot org
- Date: Wed, 21 Nov 2018 01:28:42 +0100
- Subject: [PATCH 6/8] Y2038: add function __ctime64
- References: <20181121002844.14530-1-albert.aribaud@3adev.fr>
* include/time.h
(__ctime64): Add.
* time/gmtime.c
(__ctime64): Add.
(ctime): Compile only if __TIMERSIZE != 64.
---
include/time.h | 7 +++++++
time/ctime.c | 14 ++++++++++++++
2 files changed, 21 insertions(+)
diff --git a/include/time.h b/include/time.h
index 80543e3673..0247146211 100644
--- a/include/time.h
+++ b/include/time.h
@@ -57,6 +57,13 @@ extern time_t __mktime_internal (struct tm *__tp,
struct tm *),
long int *__offset) attribute_hidden;
+/* nis/nis_print.c needs ctime, so even if ctime is not declared here,
+ we define __ctime64 as ctime so that nis/nis_print.c can get linked
+ against a function called ctime. */
+#if __TIMESIZE == 64
+# define __ctime64 ctime
+#endif
+
#if __TIMESIZE == 64
# define __localtime64 localtime
#else
diff --git a/time/ctime.c b/time/ctime.c
index 1222614f29..c20059c9a3 100644
--- a/time/ctime.c
+++ b/time/ctime.c
@@ -19,6 +19,18 @@
/* Return a string as returned by asctime which
is the representation of *T in that form. */
+char *
+__ctime64 (const __time64_t *t)
+{
+ /* The C Standard says ctime (t) is equivalent to asctime (localtime (t)).
+ In particular, ctime and asctime must yield the same pointer. */
+ return asctime (__localtime64 (t));
+}
+
+/* Provide a 32-bit variant if needed */
+
+#if __TIMESIZE != 64
+
char *
ctime (const time_t *t)
{
@@ -26,3 +38,5 @@ ctime (const time_t *t)
In particular, ctime and asctime must yield the same pointer. */
return asctime (localtime (t));
}
+
+#endif
--
2.17.1