From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 57622 invoked by alias); 7 Sep 2017 22:42:38 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 57523 invoked by uid 89); 7 Sep 2017 22:42:38 -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 02/52] Y2038: add function __difftime64 Date: Thu, 07 Sep 2017 22:42:00 -0000 Message-Id: <20170907224219.12483-3-albert.aribaud@3adev.fr> In-Reply-To: <20170907224219.12483-2-albert.aribaud@3adev.fr> References: <20170907224219.12483-1-albert.aribaud@3adev.fr> <20170907224219.12483-2-albert.aribaud@3adev.fr> X-SW-Source: 2017-09/txt/msg00318.txt.bz2 Note: the implementation expects __time64_t arguments but returns a double like its 32-bit-time counterpart, in order to remain as source-code-compatible as possible, even though the precision of a double is only about 55 bits. The implementation is simpler than its 32-bit counterpart, as it assumes that all __time64_t implementations are just 64-bit integers. Also, the implementation does not require a Y2038-proof kernel. Signed-off-by: Albert ARIBAUD (3ADEV) --- sysdeps/unix/sysv/linux/arm/Versions | 7 +++++++ time/difftime.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/sysdeps/unix/sysv/linux/arm/Versions b/sysdeps/unix/sysv/linux/arm/Versions index 7e5ba53455..d3655768c8 100644 --- a/sysdeps/unix/sysv/linux/arm/Versions +++ b/sysdeps/unix/sysv/linux/arm/Versions @@ -16,4 +16,11 @@ libc { # nptl/pthread_cond_timedwait.c uses INTERNAL_VSYSCALL(clock_gettime). __vdso_clock_gettime; } + + # Y2038 symbols are given their own version until they can be put in + # the right place + + GLIBC_Y2038 { + __difftime64; + } } diff --git a/time/difftime.c b/time/difftime.c index e5e3311744..1b2494c727 100644 --- a/time/difftime.c +++ b/time/difftime.c @@ -119,3 +119,12 @@ __difftime (time_t time1, time_t time0) return time1 < time0 ? - subtract (time0, time1) : subtract (time1, time0); } strong_alias (__difftime, difftime) + +/* Return the difference between 64-bit TIME1 and TIME0. */ +double +__difftime64 (__time64_t time1, __time64_t time0) +{ + /* Subtract the smaller integer from the larger, convert the difference to + double, and then negate if needed. */ + return time1 < time0 ? - (time0 - time1) : (time1 - time0); +} -- 2.11.0