]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Y2038: add function __settimeofday64
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Thu, 7 Sep 2017 22:41:59 +0000 (00:41 +0200)
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Wed, 24 Oct 2018 10:53:27 +0000 (12:53 +0200)
Implementing a 64-bit settimeofday requires adding a new
file to build under time/ and we cannot name that new file
'settimeofday.c' or it will break the 32-bit settimeofday
file symbol, so we call it 'settimeofday64.c'.

include/sys/time.h
sysdeps/unix/sysv/linux/settimeofday64.c [new file with mode: 0644]
time/Makefile
time/Versions
time/settimeofday.c

index ed73a445bfb8cb9361c57f3fa820e9d747b02942..792fe84568794ad81bbe8eaaacb5199eb2172293 100644 (file)
@@ -29,6 +29,8 @@ extern int __gettimeofday64 (struct __timeval64 *__tv,
 extern int __settimeofday (const struct timeval *__tv,
                           const struct timezone *__tz)
        attribute_hidden;
+extern int __settimeofday64 (const struct __timeval64 *__tv,
+                            const struct timezone *__tz);
 extern int __adjtime (const struct timeval *__delta,
                      struct timeval *__olddelta);
 extern int __getitimer (enum __itimer_which __which,
diff --git a/sysdeps/unix/sysv/linux/settimeofday64.c b/sysdeps/unix/sysv/linux/settimeofday64.c
new file mode 100644 (file)
index 0000000..1a9fa23
--- /dev/null
@@ -0,0 +1,39 @@
+/* Set the current time of day and timezone information.
+
+   Copyright (C) 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 <sysdep.h>
+#include <errno.h>
+#include <sys/time.h>
+
+int __settimeofday64(const struct __timeval64 *tv,
+                       const struct timezone *tz)
+{
+  struct timeval tv32;
+
+  if (tv && tv->tv_sec > INT_MAX)
+    {
+      __set_errno(EOVERFLOW);
+      return -1;
+    }
+
+  tv32.tv_sec = tv->tv_sec;
+  tv32.tv_usec = tv->tv_usec;
+
+  return __settimeofday(&tv32, tz);
+}
index c466206022811b1f96689ca56a2a71b0db2ca845..8354b26ab20cf48d76cf8298d277b08bad938d93 100644 (file)
@@ -32,7 +32,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                 \
            gettimeofday settimeofday adjtime tzset      \
-           gettimeofday64                               \
+           gettimeofday64 settimeofday64                \
            tzfile getitimer setitimer                   \
            stime dysize timegm ftime                    \
            getdate strptime strptime_l                  \
index f1b4cbfbc32ca3c32cb93d08d1c19436f8d620d1..1b178e43f91f17ac8af984665ad6101c1ac7e815 100644 (file)
@@ -81,5 +81,6 @@ libc {
     __futimes64;
     __lutimes64;
     __gettimeofday64;
+    __settimeofday64;
   }
 }
index 01bf4b032d64164c0152cff0348a8d2095a4da01..000ed2184964928f754f4095bde785c3897abbda 100644 (file)
@@ -29,3 +29,11 @@ __settimeofday (const struct timeval *tv, const struct timezone *tz)
 stub_warning (settimeofday)
 
 weak_alias (__settimeofday, settimeofday)
+
+int
+__settimeofday64 (const struct timeval *tv, const struct timezone *tz)
+{
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (__settimeofday64)