From patchwork Thu Sep 7 22:41:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Albert ARIBAUD X-Patchwork-Id: 22736 Received: (qmail 87566 invoked by alias); 7 Sep 2017 22:44:29 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 86974 invoked by uid 89); 7 Sep 2017 22:44:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy= X-HELO: smtp6-g21.free.fr From: "Albert ARIBAUD (3ADEV)" To: libc-alpha@sourceware.org Cc: "Albert ARIBAUD (3ADEV)" Subject: [RFC PATCH 28/52] Y2038: add function __time_t64 Date: Fri, 8 Sep 2017 00:41:55 +0200 Message-Id: <20170907224219.12483-29-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-28-albert.aribaud@3adev.fr> References: <20170907224219.12483-1-albert.aribaud@3adev.fr> <20170907224219.12483-2-albert.aribaud@3adev.fr> <20170907224219.12483-3-albert.aribaud@3adev.fr> <20170907224219.12483-4-albert.aribaud@3adev.fr> <20170907224219.12483-5-albert.aribaud@3adev.fr> <20170907224219.12483-6-albert.aribaud@3adev.fr> <20170907224219.12483-7-albert.aribaud@3adev.fr> <20170907224219.12483-8-albert.aribaud@3adev.fr> <20170907224219.12483-9-albert.aribaud@3adev.fr> <20170907224219.12483-10-albert.aribaud@3adev.fr> <20170907224219.12483-11-albert.aribaud@3adev.fr> <20170907224219.12483-12-albert.aribaud@3adev.fr> <20170907224219.12483-13-albert.aribaud@3adev.fr> <20170907224219.12483-14-albert.aribaud@3adev.fr> <20170907224219.12483-15-albert.aribaud@3adev.fr> <20170907224219.12483-16-albert.aribaud@3adev.fr> <20170907224219.12483-17-albert.aribaud@3adev.fr> <20170907224219.12483-18-albert.aribaud@3adev.fr> <20170907224219.12483-19-albert.aribaud@3adev.fr> <20170907224219.12483-20-albert.aribaud@3adev.fr> <20170907224219.12483-21-albert.aribaud@3adev.fr> <20170907224219.12483-22-albert.aribaud@3adev.fr> <20170907224219.12483-23-albert.aribaud@3adev.fr> <20170907224219.12483-24-albert.aribaud@3adev.fr> <20170907224219.12483-25-albert.aribaud@3adev.fr> <20170907224219.12483-26-albert.aribaud@3adev.fr> <20170907224219.12483-27-albert.aribaud@3adev.fr> <20170907224219.12483-28-albert.aribaud@3adev.fr> These implementations use only 32-bit time kernel syscalls. Therefore, stime() will always set errno to EOVERFLOW and return -1 for dates beyond Y2038. Signed-off-by: Albert ARIBAUD (3ADEV) --- sysdeps/posix/time.c | 26 ++++++++++++++++++++++++++ sysdeps/unix/sysv/linux/time.c | 22 ++++++++++++++++++++++ time/Versions | 1 + time/time.c | 13 +++++++++++++ 4 files changed, 62 insertions(+) diff --git a/sysdeps/posix/time.c b/sysdeps/posix/time.c index 32ca177514..a4c4a03c55 100644 --- a/sysdeps/posix/time.c +++ b/sysdeps/posix/time.c @@ -38,3 +38,29 @@ time (time_t *t) return result; } libc_hidden_def (time) + +/* 64-bit time version */ + +extern int __y2038_linux_support; + +__time64_t +__time_t64 (__time64_t *t) +{ + struct timeval tv32; + __time64_t result; + + if (__y2038_linux_support) + { + /* TODO: implement using 64-bit time syscall */ + } + + if (__gettimeofday (&tv32, (struct timezone *) NULL)) + result = (__time64_t) -1; + else + result = (__time64_t) tv32.tv_sec; + + if (t != NULL) + *t = result; + + return result; +} diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c index 72d4040cbc..b6c7e61844 100644 --- a/sysdeps/unix/sysv/linux/time.c +++ b/sysdeps/unix/sysv/linux/time.c @@ -34,6 +34,28 @@ time (time_t *t) } libc_hidden_def (time) +/* 64-BIT TIME VERSION */ + +extern int __y2038_linux_support; + +__time64_t +__time_t64 (__time64_t *t) +{ + INTERNAL_SYSCALL_DECL (err); + __time64_t res; + + if (__y2038_linux_support) + { + /* TODO: implement using 64-bit time syscall */ + } + + res = INTERNAL_SYSCALL (time, err, 1, NULL); + /* There cannot be any error. */ + if (t != NULL) + *t = res; + return res; +} + #else # include diff --git a/time/Versions b/time/Versions index 3fe860862a..02dc8d6146 100644 --- a/time/Versions +++ b/time/Versions @@ -71,5 +71,6 @@ libc { GLIBC_Y2038 { __timespec_get64; + __time_t64; } } diff --git a/time/time.c b/time/time.c index e375035265..a487068468 100644 --- a/time/time.c +++ b/time/time.c @@ -31,3 +31,16 @@ time (time_t *timer) libc_hidden_def (time) stub_warning (time) + +/* 64-bit time version */ + +__time64_t +__time_t64 (__time64_ *timer) +{ + __set_errno (ENOSYS); + + if (timer != NULL) + *timer = (__time64_t) -1; + return (__time64_t) -1; +} +libc_hidden_def (__time_t64)