]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Y2038: add function __time64
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Thu, 7 Sep 2017 22:41:55 +0000 (00:41 +0200)
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Wed, 24 Oct 2018 10:53:27 +0000 (12:53 +0200)
This provides a generic Posix implementation based on calling
__gettimeofday64().

sysdeps/posix/time64.c [new file with mode: 0644]
time/Makefile
time/Versions
time/time.c

diff --git a/sysdeps/posix/time64.c b/sysdeps/posix/time64.c
new file mode 100644 (file)
index 0000000..4a58228
--- /dev/null
@@ -0,0 +1,43 @@
+/* Get the 64-bit current time
+ * 
+   Copyright (C) 1991-2018 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>            /* For NULL.  */
+#include <time.h>
+#include <sys/time.h>
+
+
+/* Return the current time as a `time_t' and also put it in *T if T is
+   not NULL.  Time is represented as seconds from Jan 1 00:00:00 1970.  */
+
+__time64_t
+__time64 (__time64_t *t)
+{
+  struct __timeval64 tv;
+  __time64_t result;
+
+  if (__gettimeofday64 (&tv, (struct timezone *) NULL))
+    result = (__time64_t) -1;
+  else
+    result = tv.tv_sec;
+
+  if (t != NULL)
+    *t = result;
+
+  return result;
+}
index 8354b26ab20cf48d76cf8298d277b08bad938d93..d4c553fc3e4900aa76f147d74e29e6a4bf4085c5 100644 (file)
@@ -31,6 +31,7 @@ headers := time.h sys/time.h sys/timeb.h bits/time.h                  \
 
 routines := offtime asctime clock ctime ctime_r difftime \
            gmtime localtime mktime time                 \
+           time64                                       \
            gettimeofday settimeofday adjtime tzset      \
            gettimeofday64 settimeofday64                \
            tzfile getitimer setitimer                   \
index 1b178e43f91f17ac8af984665ad6101c1ac7e815..b5e070f82b214d58ec4d49a1f9ca62de2be4534f 100644 (file)
@@ -82,5 +82,6 @@ libc {
     __lutimes64;
     __gettimeofday64;
     __settimeofday64;
+    __time64;
   }
 }
index 4996d26f13cfae0429a7e953b9333b48fc59defc..9703c724640315fb6f8b3ffd15bc609fa4bb5293 100644 (file)
@@ -31,3 +31,16 @@ time (time_t *timer)
 libc_hidden_def (time)
 
 stub_warning (time)
+
+/* 64-bit time version */
+
+__time64_t
+__time64 (__time64_ *timer)
+{
+  __set_errno (ENOSYS);
+
+  if (timer != NULL)
+    *timer = (__time64_t) -1;
+  return (__time64_t) -1;
+}
+libc_hidden_def (__time64)