diff mbox

[7/8] Y2038: add function __ctime64_r

Message ID 20181121002844.14530-8-albert.aribaud@3adev.fr
State New
Headers show

Commit Message

Albert ARIBAUD Nov. 21, 2018, 12:28 a.m. UTC
* include/time.h
	(__ctime64_r): Add.
	* time/ctime_r.c
	(__ctime64_r): Add.
	(__ctime_r): Compile only if __TIMERSIZE != 64.
---
 include/time.h |  4 ++++
 time/ctime_r.c | 13 +++++++++++++
 2 files changed, 17 insertions(+)
diff mbox

Patch

diff --git a/include/time.h b/include/time.h
index 0247146211..c26cfb40f6 100644
--- a/include/time.h
+++ b/include/time.h
@@ -64,6 +64,10 @@  extern time_t __mktime_internal (struct tm *__tp,
 # define __ctime64 ctime
 #endif
 
+#if __TIMESIZE == 64
+# define __ctime64_r ctime_r
+#endif
+
 #if __TIMESIZE == 64
 # define __localtime64 localtime
 #else
diff --git a/time/ctime_r.c b/time/ctime_r.c
index c111146d76..be4e62c86d 100644
--- a/time/ctime_r.c
+++ b/time/ctime_r.c
@@ -21,9 +21,22 @@ 
 
 /* Return a string as returned by asctime which is the representation
    of *T in that form.  Reentrant version.  */
+char *
+__ctime64_r (const __time64_t *t, char *buf)
+{
+  struct tm tm;
+  return __asctime_r (__localtime64_r (t, &tm), buf);
+}
+
+/* Provide a 32-bit variant if needed */
+
+#if __TIMESIZE != 64
+
 char *
 ctime_r (const time_t *t, char *buf)
 {
   struct tm tm;
   return __asctime_r (__localtime_r (t, &tm), buf);
 }
+
+#endif