[6/8] Y2038: add function __ctime64

Message ID 20181121002844.14530-7-albert.aribaud@3adev.fr
State Superseded
Headers show
Series
  • Y2038 struct tm related patches
Related show

Commit Message

Albert ARIBAUD (3ADEV) Nov. 21, 2018, 12:28 a.m.
* 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(+)

-- 
2.17.1

Patch

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