From patchwork Thu Sep 7 22:41:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Albert ARIBAUD (3ADEV)" X-Patchwork-Id: 811196 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-84320-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="fngUaLFt"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xpFpV5LXxz9sCZ for ; Fri, 8 Sep 2017 08:42:58 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=aIDUZVNLw0G/DjR8YGqOBVjzuwR0h3a d2tCMxBVYWWrpp6nQIOOCxXGPuYE9bvuICaFePmdQJsWXn8EXpSCwtWZADSAYTyl lAlLJSZiAf1HZUWqWcfzBeLSJ66fqxvbNK9OpEjYPNq7mN29wNa97E9EhcyFDvpo sRuTPSA/lucs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=jjlwUHSLg1yQPLPxhcJ0dWBSirg=; b=fngUa LFt6SQ6dFuzEYF7PTGnOzV4v/UhiDhdH+PrBuqZJTHAFVbkuFTPr/wPRla+qjRdZ J2/s1I25Cpfk6lcwSMZQRpLLdiedbhntx9c+4XIbBNloShCnjBDQerh1Wc9Lagjq rqqO/7rZZ+MxCyQsoaS0nutfrbAA/AwyiGATSE= 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-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 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: Fri, 8 Sep 2017 00:41:29 +0200 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> 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); +}