From patchwork Tue Jun 10 16:59:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 358059 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 426391400B2 for ; Wed, 11 Jun 2014 02:59:59 +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=rOLrbC67Bf+3kocWGnPsc1if6h6bg EV1tIe43F8JR8/T6LrsZZ7SE0LCZFmvVRMApkVciIlyb90gbpeB82celWUOSfkJe Hyo5AZb8+4L/5G24bo0RSpJFgckJKw55igNAh0iW6LFSvQGvWGzCF+CrzKyRYfZE 5K5litFDsjINmA= 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=FS7Q+XousCfFUyObylOG+HgEn9o=; b=ueI UoLPaYt7y5/vRQK+BvJeRTCWUSUiKxUVQc9IRlQtDiDBRdU22GmJHC+NIhIZuRZQ NWsIZuU38/5wWQC+oUzU+iq+PiIojCzDlOL+GqIkkJmGfD1QhTRQklg1YiOW/Bqb s8myI+NtxhSQRzoKvqvPvKDErB8i9YJUcoc7iXsc= Received: (qmail 10023 invoked by alias); 10 Jun 2014 16:59:49 -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 9960 invoked by uid 89); 10 Jun 2014 16:59:48 -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 3/5] ARM: Cleanup fenv implementation Date: Tue, 10 Jun 2014 17:59:39 +0100 Message-ID: <003601cf84cd$5e2fb260$1a8f1720$@com> MIME-Version: 1.0 X-MC-Unique: 114061017594402801 Hi, This is a series of patches which improves the ARM fenv implementation. Add _FPU_MASK_RM and use it instead of FE_TOWARDZERO. ChangeLog: 2014-06-10 Wilco * sysdeps/arm/fpu_control.h (_FPU_MASK_RM): Define. * sysdeps/arm/fenv_private.h (libc_fesetround_vfp) (libc_feholdexcept_setround_vfp) (libc_feholdsetround_vfp) (libc_feresetround_vfp) (libc_feholdsetround_vfp_ctx) (libc_feresetround_vfp_ctx): Use _FPU_MASK_RM. * sysdeps/arm/fesetround.c (fesetround): Use _FPU_MASK_RM. * sysdeps/arm/get-rounding-mode.h (get_rounding_mode): Use _FPU_MASK_RM. --- sysdeps/arm/fenv_private.h | 16 ++++++++-------- sysdeps/arm/fesetround.c | 3 +-- sysdeps/arm/fpu_control.h | 4 ++-- sysdeps/arm/get-rounding-mode.h | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/sysdeps/arm/fenv_private.h b/sysdeps/arm/fenv_private.h index bff8acd..743df18 100644 --- a/sysdeps/arm/fenv_private.h +++ b/sysdeps/arm/fenv_private.h @@ -43,8 +43,8 @@ libc_fesetround_vfp (int round) _FPU_GETCW (fpscr); /* Set new rounding mode if different. */ - if (__glibc_unlikely ((fpscr & FE_TOWARDZERO) != round)) - _FPU_SETCW ((fpscr & ~FE_TOWARDZERO) | round); + if (__glibc_unlikely ((fpscr & _FPU_MASK_RM) != round)) + _FPU_SETCW ((fpscr & ~_FPU_MASK_RM) | round); } static __always_inline void @@ -57,7 +57,7 @@ libc_feholdexcept_setround_vfp (fenv_t *envp, int round) /* Clear exception flags, set all exceptions to non-stop, and set new rounding mode. */ - fpscr &= ~(_FPU_MASK_EXCEPT | FE_TOWARDZERO); + fpscr &= ~(_FPU_MASK_EXCEPT | _FPU_MASK_RM); _FPU_SETCW (fpscr | round); } @@ -70,8 +70,8 @@ libc_feholdsetround_vfp (fenv_t *envp, int round) envp->__cw = fpscr; /* Set new rounding mode if different. */ - if (__glibc_unlikely ((fpscr & FE_TOWARDZERO) != round)) - _FPU_SETCW ((fpscr & ~FE_TOWARDZERO) | round); + if (__glibc_unlikely ((fpscr & _FPU_MASK_RM) != round)) + _FPU_SETCW ((fpscr & ~_FPU_MASK_RM) | round); } static __always_inline void @@ -82,7 +82,7 @@ libc_feresetround_vfp (fenv_t *envp) _FPU_GETCW (fpscr); /* Check whether rounding modes are different. */ - round = (envp->__cw ^ fpscr) & FE_TOWARDZERO; + round = (envp->__cw ^ fpscr) & _FPU_MASK_RM; /* Restore the rounding mode if it was changed. */ if (__glibc_unlikely (round != 0)) @@ -150,7 +150,7 @@ libc_feholdsetround_vfp_ctx (struct rm_ctx *ctx, int r) ctx->env.__cw = fpscr; /* Check whether rounding modes are different. */ - round = (fpscr ^ r) & FE_TOWARDZERO; + round = (fpscr ^ r) & _FPU_MASK_RM; /* Set the rounding mode if changed. */ if (__glibc_unlikely (round != 0)) @@ -169,7 +169,7 @@ libc_feresetround_vfp_ctx (struct rm_ctx *ctx) fpu_control_t fpscr; _FPU_GETCW (fpscr); - fpscr = (fpscr & ~FE_TOWARDZERO) | (ctx->env.__cw & FE_TOWARDZERO); + fpscr = (fpscr & ~_FPU_MASK_RM) | (ctx->env.__cw & _FPU_MASK_RM); _FPU_SETCW (fpscr); } } diff --git a/sysdeps/arm/fesetround.c b/sysdeps/arm/fesetround.c index 2e21925..530a6ba 100644 --- a/sysdeps/arm/fesetround.c +++ b/sysdeps/arm/fesetround.c @@ -28,8 +28,7 @@ fesetround (int round) if (!ARM_HAVE_VFP) return (round == FE_TONEAREST) ? 0 : 1; - /* Fail if the rounding mode is not valid. */ - if (round & ~FE_TOWARDZERO) + if (round & ~_FPU_MASK_RM) return 1; libc_fesetround_vfp (round); diff --git a/sysdeps/arm/fpu_control.h b/sysdeps/arm/fpu_control.h index 0377697..dbce935 100644 --- a/sysdeps/arm/fpu_control.h +++ b/sysdeps/arm/fpu_control.h @@ -37,8 +37,8 @@ extern fpu_control_t __fpu_control; #define _FPU_MASK_UM 0x00000800 /* underflow */ #define _FPU_MASK_PM 0x00001000 /* inexact */ -#define _FPU_MASK_NZCV 0xF0000000 /* NZCV flags */ - +#define _FPU_MASK_NZCV 0xf0000000 /* NZCV flags */ +#define _FPU_MASK_RM 0x00c00000 /* rounding mode */ #define _FPU_MASK_EXCEPT 0x00001f1f /* all exception flags */ /* Some bits in the FPSCR are not yet defined. They must be preserved when diff --git a/sysdeps/arm/get-rounding-mode.h b/sysdeps/arm/get-rounding-mode.h index a1ecf51..f50ef24 100644 --- a/sysdeps/arm/get-rounding-mode.h +++ b/sysdeps/arm/get-rounding-mode.h @@ -36,7 +36,7 @@ get_rounding_mode (void) return FE_TONEAREST; _FPU_GETCW (fpscr); - return fpscr & FE_TOWARDZERO; + return fpscr & _FPU_MASK_RM; } #endif /* get-rounding-mode.h */