From patchwork Tue Jun 10 17:00:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 358060 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 D06D21400B2 for ; Wed, 11 Jun 2014 03:00:31 +1000 (EST) 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:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=HYPxdjt9nMwTTTx4vi7KFHP3QPKxW uQg/YXmMjPmJ3nNb4CbdFdrHdztTnbvdlastE+UMZXaAi46gP/RbLMIrzmJBLFAQ Jm2pxbJIVHV9iYCdkZcMXA8TfeGpUxRdS5TZ+DsQQHZylRAwmA4z2bY4Qb4CqmuU dLaKQyQKrfxnNM= 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:subject:date:message-id:mime-version :content-type; s=default; bh=lxvXPRIZWQoJ8icujORPh8AyMs8=; b=dYV s40mMoDOhRdUoGZCS+F/J0Qgn4nkbd2X2fT8JciT0fdEiDFYxqJdEssWu6C+rkqm 5GdzJFei2n5IhJdtdSuc/1NU/NqW34arxfZHkw9mQ59IGY3gtwlWAHI70T3+LpRK fQaAhfajk9qIeCB3Og/r75iZfI78p6Sev9aARs94= Received: (qmail 12343 invoked by alias); 10 Jun 2014 17:00:24 -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 12141 invoked by uid 89); 10 Jun 2014 17:00:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco" To: "GNU C Library" Subject: [PATCH 4/5] ARM: Cleanup fenv implementation Date: Tue, 10 Jun 2014 18:00:12 +0100 Message-ID: <003a01cf84cd$71cc24c0$55646e40$@com> MIME-Version: 1.0 X-MC-Unique: 114061018001604101 Hi, This is a series of patches which improves the ARM fenv implementation. Improve rounding mode check in libc_fesetround_vfp and libc_feholdsetround_vfp so it ignores out of range values. ChangeLog: 2014-06-10 Wilco * sysdeps/arm/fenv_private.h (libc_fesetround_vfp) (libc_feholdsetround_vfp): Improve rounding mode check. --- sysdeps/arm/fenv_private.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sysdeps/arm/fenv_private.h b/sysdeps/arm/fenv_private.h index 743df18..1d91fa6 100644 --- a/sysdeps/arm/fenv_private.h +++ b/sysdeps/arm/fenv_private.h @@ -42,9 +42,12 @@ libc_fesetround_vfp (int round) _FPU_GETCW (fpscr); + /* Check whether rounding modes are different. */ + round = (fpscr ^ round) & _FPU_MASK_RM; + /* Set new rounding mode if different. */ - if (__glibc_unlikely ((fpscr & _FPU_MASK_RM) != round)) - _FPU_SETCW ((fpscr & ~_FPU_MASK_RM) | round); + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpscr ^ round); } static __always_inline void @@ -69,9 +72,12 @@ libc_feholdsetround_vfp (fenv_t *envp, int round) _FPU_GETCW (fpscr); envp->__cw = fpscr; + /* Check whether rounding modes are different. */ + round = (fpscr ^ round) & _FPU_MASK_RM; + /* Set new rounding mode if different. */ - if (__glibc_unlikely ((fpscr & _FPU_MASK_RM) != round)) - _FPU_SETCW ((fpscr & ~_FPU_MASK_RM) | round); + if (__glibc_unlikely (round != 0)) + _FPU_SETCW (fpscr ^ round); } static __always_inline void