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 Dijkstra X-Patchwork-Id: 1421 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