From patchwork Fri May 23 17:30:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 351992 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 4AB1914009C for ; Sat, 24 May 2014 03:31:07 +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=BS7ujDAO8XO0TOYyiX/gGQhvwchii WZ3fFX6vAp+yfx/mlMBu51c8zUc4U3RMyWtgsxKVLahzWIa/074WtrHgmWV4qKOx aPb1IgxxPHrCxhleBEVe6noEcv7ngT0rKxKWBkG82LvMkvvxQHtuWOX+p7ak/PZ0 cKSD5uAiyNSsnk= 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=0LGd4PjyWvZ5R2CAw81BDdbZT5Y=; b=BrF e2bAwbntJhwQCTP5oGm/w/5GKNrBDG0XKqMNUiqAHwPavaqkPfmLH5qphAHvO8ox PKsoMCljHGXCTbdA5rQHJWtaegfgm9lD03HgR/RROalzdfQ7d1Cu6JTDrFlSdyYO TIEdX+7vqy61admqjoA0cbmB+XtS0Hu/5X2wiq9A= Received: (qmail 31964 invoked by alias); 23 May 2014 17:31:01 -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 31945 invoked by uid 89); 23 May 2014 17:30:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 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: Subject: [PATCH] ARM: Use libc calls for fenv functions Date: Fri, 23 May 2014 18:30:46 +0100 Message-ID: <001901cf76ac$bb8fa700$32aef500$@com> MIME-Version: 1.0 X-MC-Unique: 114052318305500701 Hi, This patch uses libc calls defined by fenv_private.h to implement several fenv functions rather than duplicating functionality. To make this work for softfp builds, ensure functions in fenv_private are not conditionally compiled. OK for commit? Wilco ChangeLog: 2014-05-23 Wilco * sysdeps/arm/fegetround.c (fegetround): Call get_rounding_mode. * sysdeps/arm/feholdexcpt.c (feholdexcept): Call libc_feholdexcept_vfp. * sysdeps/arm/fesetround.c (fesetround): Call libc_fesetround_vfp. * sysdeps/arm/fgetexcptflg.c (fegetexceptflag): Call libc_fetestexcept_vfp. * sysdeps/arm/ftestexcept.c (fetestexcept): Call libc_fetestexcept_vfp. * sysdeps/arm/fenv_private.h: Move libc_*_vfp functions outside of __SOFTFP__ ifdef so that they can be built for softfp. --- sysdeps/arm/fegetround.c | 14 +----- sysdeps/arm/feholdexcpt.c | 16 +------ sysdeps/arm/fenv_private.h | 108 ++++++++++++++++++++++---------------------- sysdeps/arm/fesetround.c | 9 +--- sysdeps/arm/fgetexcptflg.c | 9 +--- sysdeps/arm/ftestexcept.c | 10 +--- 6 files changed, 64 insertions(+), 102 deletions(-) diff --git a/sysdeps/arm/fegetround.c b/sysdeps/arm/fegetround.c index 1c9c151..fbad0b3 100644 --- a/sysdeps/arm/fegetround.c +++ b/sysdeps/arm/fegetround.c @@ -16,22 +16,12 @@ License along with the GNU C Library. If not, see . */ -#include -#include -#include +#include int fegetround (void) { - fpu_control_t fpscr; - - /* FE_TONEAREST is the only supported rounding mode - if a VFP unit isn't present. */ - if (!ARM_HAVE_VFP) - return FE_TONEAREST; - - _FPU_GETCW (fpscr); - return fpscr & FE_TOWARDZERO; + return get_rounding_mode (); } libm_hidden_def (fegetround) diff --git a/sysdeps/arm/feholdexcpt.c b/sysdeps/arm/feholdexcpt.c index 258ba66..2d79e0c 100644 --- a/sysdeps/arm/feholdexcpt.c +++ b/sysdeps/arm/feholdexcpt.c @@ -16,30 +16,18 @@ License along with the GNU C Library. If not, see . */ -#include -#include +#include #include int feholdexcept (fenv_t *envp) { - fpu_control_t fpscr; - /* Fail if a VFP unit isn't present. */ if (!ARM_HAVE_VFP) return 1; - _FPU_GETCW (fpscr); - envp->__cw = fpscr; - - /* Now set all exceptions to non-stop. */ - fpscr &= ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT); - - /* And clear all exception flags. */ - fpscr &= ~FE_ALL_EXCEPT; - - _FPU_SETCW (fpscr); + libc_feholdexcept_vfp (envp); return 0; } diff --git a/sysdeps/arm/fenv_private.h b/sysdeps/arm/fenv_private.h index e246fb5..bff8acd 100644 --- a/sysdeps/arm/fenv_private.h +++ b/sysdeps/arm/fenv_private.h @@ -22,8 +22,6 @@ #include #include -#ifndef __SOFTFP__ - static __always_inline void libc_feholdexcept_vfp (fenv_t *envp) { @@ -142,49 +140,6 @@ libc_feupdateenv_vfp (const fenv_t *envp) libc_feupdateenv_test_vfp (envp, 0); } -#define libc_feholdexcept libc_feholdexcept_vfp -#define libc_feholdexceptf libc_feholdexcept_vfp -#define libc_feholdexceptl libc_feholdexcept_vfp - -#define libc_fesetround libc_fesetround_vfp -#define libc_fesetroundf libc_fesetround_vfp -#define libc_fesetroundl libc_fesetround_vfp - -#define libc_feresetround libc_feresetround_vfp -#define libc_feresetroundf libc_feresetround_vfp -#define libc_feresetroundl libc_feresetround_vfp - -#define libc_feresetround_noex libc_fesetenv_vfp -#define libc_feresetround_noexf libc_fesetenv_vfp -#define libc_feresetround_noexl libc_fesetenv_vfp - -#define libc_feholdexcept_setround libc_feholdexcept_setround_vfp -#define libc_feholdexcept_setroundf libc_feholdexcept_setround_vfp -#define libc_feholdexcept_setroundl libc_feholdexcept_setround_vfp - -#define libc_feholdsetround libc_feholdsetround_vfp -#define libc_feholdsetroundf libc_feholdsetround_vfp -#define libc_feholdsetroundl libc_feholdsetround_vfp - -#define libc_fetestexcept libc_fetestexcept_vfp -#define libc_fetestexceptf libc_fetestexcept_vfp -#define libc_fetestexceptl libc_fetestexcept_vfp - -#define libc_fesetenv libc_fesetenv_vfp -#define libc_fesetenvf libc_fesetenv_vfp -#define libc_fesetenvl libc_fesetenv_vfp - -#define libc_feupdateenv libc_feupdateenv_vfp -#define libc_feupdateenvf libc_feupdateenv_vfp -#define libc_feupdateenvl libc_feupdateenv_vfp - -#define libc_feupdateenv_test libc_feupdateenv_test_vfp -#define libc_feupdateenv_testf libc_feupdateenv_test_vfp -#define libc_feupdateenv_testl libc_feupdateenv_test_vfp - -/* We have support for rounding mode context. */ -#define HAVE_RM_CTX 1 - static __always_inline void libc_feholdsetround_vfp_ctx (struct rm_ctx *ctx, int r) { @@ -232,17 +187,62 @@ libc_fesetenv_vfp_ctx (struct rm_ctx *ctx) _FPU_SETCW (new_fpscr); } -#define libc_feholdsetround_ctx libc_feholdsetround_vfp_ctx -#define libc_feresetround_ctx libc_feresetround_vfp_ctx -#define libc_feresetround_noex_ctx libc_fesetenv_vfp_ctx +#ifndef __SOFTFP__ + +# define libc_feholdexcept libc_feholdexcept_vfp +# define libc_feholdexceptf libc_feholdexcept_vfp +# define libc_feholdexceptl libc_feholdexcept_vfp + +# define libc_fesetround libc_fesetround_vfp +# define libc_fesetroundf libc_fesetround_vfp +# define libc_fesetroundl libc_fesetround_vfp + +# define libc_feresetround libc_feresetround_vfp +# define libc_feresetroundf libc_feresetround_vfp +# define libc_feresetroundl libc_feresetround_vfp + +# define libc_feresetround_noex libc_fesetenv_vfp +# define libc_feresetround_noexf libc_fesetenv_vfp +# define libc_feresetround_noexl libc_fesetenv_vfp + +# define libc_feholdexcept_setround libc_feholdexcept_setround_vfp +# define libc_feholdexcept_setroundf libc_feholdexcept_setround_vfp +# define libc_feholdexcept_setroundl libc_feholdexcept_setround_vfp + +# define libc_feholdsetround libc_feholdsetround_vfp +# define libc_feholdsetroundf libc_feholdsetround_vfp +# define libc_feholdsetroundl libc_feholdsetround_vfp + +# define libc_fetestexcept libc_fetestexcept_vfp +# define libc_fetestexceptf libc_fetestexcept_vfp +# define libc_fetestexceptl libc_fetestexcept_vfp + +# define libc_fesetenv libc_fesetenv_vfp +# define libc_fesetenvf libc_fesetenv_vfp +# define libc_fesetenvl libc_fesetenv_vfp + +# define libc_feupdateenv libc_feupdateenv_vfp +# define libc_feupdateenvf libc_feupdateenv_vfp +# define libc_feupdateenvl libc_feupdateenv_vfp + +# define libc_feupdateenv_test libc_feupdateenv_test_vfp +# define libc_feupdateenv_testf libc_feupdateenv_test_vfp +# define libc_feupdateenv_testl libc_feupdateenv_test_vfp + +/* We have support for rounding mode context. */ +#define HAVE_RM_CTX 1 + +# define libc_feholdsetround_ctx libc_feholdsetround_vfp_ctx +# define libc_feresetround_ctx libc_feresetround_vfp_ctx +# define libc_feresetround_noex_ctx libc_fesetenv_vfp_ctx -#define libc_feholdsetroundf_ctx libc_feholdsetround_vfp_ctx -#define libc_feresetroundf_ctx libc_feresetround_vfp_ctx -#define libc_feresetround_noexf_ctx libc_fesetenv_vfp_ctx +# define libc_feholdsetroundf_ctx libc_feholdsetround_vfp_ctx +# define libc_feresetroundf_ctx libc_feresetround_vfp_ctx +# define libc_feresetround_noexf_ctx libc_fesetenv_vfp_ctx -#define libc_feholdsetroundl_ctx libc_feholdsetround_vfp_ctx -#define libc_feresetroundl_ctx libc_feresetround_vfp_ctx -#define libc_feresetround_noexl_ctx libc_fesetenv_vfp_ctx +# define libc_feholdsetroundl_ctx libc_feholdsetround_vfp_ctx +# define libc_feresetroundl_ctx libc_feresetround_vfp_ctx +# define libc_feresetround_noexl_ctx libc_fesetenv_vfp_ctx #endif diff --git a/sysdeps/arm/fesetround.c b/sysdeps/arm/fesetround.c index d1b92dc..d79f910 100644 --- a/sysdeps/arm/fesetround.c +++ b/sysdeps/arm/fesetround.c @@ -16,16 +16,13 @@ License along with the GNU C Library. If not, see . */ -#include -#include +#include #include int fesetround (int round) { - fpu_control_t fpscr; - /* FE_TONEAREST is the only supported rounding mode if a VFP unit isn't present. */ if (!ARM_HAVE_VFP) @@ -35,9 +32,7 @@ fesetround (int round) if (round & ~FE_TOWARDZERO) return 1; - _FPU_GETCW (fpscr); - fpscr = (fpscr & ~FE_TOWARDZERO) | round; - _FPU_SETCW (fpscr); + libc_fesetround_vfp (round); return 0; } diff --git a/sysdeps/arm/fgetexcptflg.c b/sysdeps/arm/fgetexcptflg.c index 63fdfbf..994555c 100644 --- a/sysdeps/arm/fgetexcptflg.c +++ b/sysdeps/arm/fgetexcptflg.c @@ -17,22 +17,17 @@ License along with the GNU C Library. If not, see . */ -#include -#include +#include #include int fegetexceptflag (fexcept_t *flagp, int excepts) { - fpu_control_t fpscr; - /* Fail if a VFP unit isn't present. */ if (!ARM_HAVE_VFP) return 1; - _FPU_GETCW (fpscr); - - *flagp = fpscr & excepts & FE_ALL_EXCEPT; + *flagp = libc_fetestexcept_vfp (excepts); return 0; } diff --git a/sysdeps/arm/ftestexcept.c b/sysdeps/arm/ftestexcept.c index de082b2..9d1f369 100644 --- a/sysdeps/arm/ftestexcept.c +++ b/sysdeps/arm/ftestexcept.c @@ -16,23 +16,17 @@ License along with the GNU C Library. If not, see . */ -#include -#include +#include #include int fetestexcept (int excepts) { - fpu_control_t fpscr; - /* Return no exception flags if a VFP unit isn't present. */ if (!ARM_HAVE_VFP) return 0; - /* Get current exceptions. */ - _FPU_GETCW (fpscr); - - return fpscr & excepts & FE_ALL_EXCEPT; + return libc_fetestexcept_vfp (excepts); } libm_hidden_def (fetestexcept)