[RFC,05/52] Y2038: add function __timegm64

Message ID 20170907224219.12483-6-albert.aribaud@3adev.fr
State New
Headers show
Series
  • Make GLIBC Y2038-proof
Related show

Commit Message

Albert ARIBAUD Sept. 7, 2017, 10:41 p.m.
Implementation is based on the same __mktime64_internal function
which was introduced in the '__mktime64' implementation change.

Again, the implementation does not require a Y2038-proof kernel.

Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
 sysdeps/unix/sysv/linux/arm/Versions |  1 +
 time/timegm.c                        | 11 +++++++++++
 2 files changed, 12 insertions(+)

Patch

diff --git a/sysdeps/unix/sysv/linux/arm/Versions b/sysdeps/unix/sysv/linux/arm/Versions
index 546d7c60ee..f7feda3650 100644
--- a/sysdeps/unix/sysv/linux/arm/Versions
+++ b/sysdeps/unix/sysv/linux/arm/Versions
@@ -26,5 +26,6 @@  libc {
     __gmtime64; __gmtime64_r;
     __localtime64; __localtime64_r;
     __mktime64; __timelocal64_r;
+    __timegm64;
   }
 }
diff --git a/time/timegm.c b/time/timegm.c
index b0f5d16d16..0c8879285a 100644
--- a/time/timegm.c
+++ b/time/timegm.c
@@ -36,6 +36,9 @@ 
 time_t __mktime_internal (struct tm *,
 			  struct tm * (*) (time_t const *, struct tm *),
 			  time_t *);
+__time64_t __mktime64_internal (struct tm *,
+				struct tm * (*) (__time64_t const *, struct tm *),
+				__time64_t *);
 #endif
 
 time_t
@@ -45,3 +48,11 @@  timegm (struct tm *tmp)
   tmp->tm_isdst = 0;
   return __mktime_internal (tmp, __gmtime_r, &gmtime_offset);
 }
+
+__time64_t
+__timegm64 (struct tm *tmp)
+{
+  static __time64_t gmtime64_offset;
+  tmp->tm_isdst = 0;
+  return __mktime64_internal (tmp, __gmtime64_r, &gmtime64_offset);
+}