From patchwork Wed Apr 30 22:15:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Miller X-Patchwork-Id: 772 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id AD5EE36007D for ; Wed, 30 Apr 2014 15:16:02 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14307373) id 2CC21148CFAB; Wed, 30 Apr 2014 15:16:02 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx21.g.dreamhost.com 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 homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id CF37A138EB1F for ; Wed, 30 Apr 2014 15:16:01 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:message-id:to:subject:from:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=Xl4 1gDukDFUB0R+teQAwPh4VrGQhhJ46lNZ5XKDAZr8FIzOz4cCdJ6cyNvLSGojnhUx 66mSIKR2PIQdiXasRFxAZfC9Dz8fQuN1bZ+X6JGa5cLAkl8ehbO4bLQBwKl1hGrX mk52J6ZuzrDNcCEp6V3MrL+VWEHykK/tAUw8gw7g= 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:date:message-id:to:subject:from:mime-version :content-type:content-transfer-encoding; s=default; bh=4oDGLwuS8 Dqf+oBpv/POC019CkE=; b=ro9444U9Rg0Y55Yvcih4bF5h/XRlo9xxIEAiV10MX l2EmpE5sk/5aYEM8wzeZBQXC7Oy2lIqNlOINaYeuxYJw/n6m4NdWE9inZ4SoN9L9 AT20jMohhgEKZSvZ+hFMKa4EEHqm8I6gUWAvUSiRofGvJwmLhRnNlb7fZQxKRPm7 MA= Received: (qmail 14211 invoked by alias); 30 Apr 2014 22:15:58 -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 14172 invoked by uid 89); 30 Apr 2014 22:15:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: shards.monkeyblade.net Date: Wed, 30 Apr 2014 18:15:49 -0400 (EDT) Message-Id: <20140430.181549.2255102165984203865.davem@davemloft.net> To: libc-alpha@sourceware.org Subject: [PATCH COMMITTED] Add round-mode context support to sparc. From: David Miller Mime-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in * sysdeps/sparc/fpu/fenv_private.h (HAVE_RM_CTX): Define. (libc_feholdexcept_setround_sparc_ctx): New function. (libc_fesetenv_sparc_ctx): Likewise. (libc_feupdateenv_sparc_ctx): Likewise. (libc_feholdsetround_sparc_ctx): Likewise. (libc_feholdexcept_setround_ctx): Define. (libc_feholdexcept_setroundf_ctx): Likewise. (libc_feholdexcept_setroundl_ctx): Likewise. (libc_fesetenv_ctx): Likewise. (libc_fesetenvf_ctx): Likewise. (libc_fesetenvl_ctx): Likewise. (libc_feupdateenv_ctx): Likewise. (libc_feupdateenvf_ctx): Likewise. (libc_feupdateenvl_ctx): Likewise. (libc_feresetround_ctx): Likewise. (libc_feresetroundf_ctx): Likewise. (libc_feresetroundl_ctx): Likewise. (libc_feholdsetround_ctx): Likewise. (libc_feholdsetroundf_ctx): Likewise. (libc_feholdsetroundl_ctx): Likewise. --- ChangeLog | 21 +++++++++++++ sysdeps/sparc/fpu/fenv_private.h | 64 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) diff --git a/ChangeLog b/ChangeLog index 44ddb28..72cc597 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2014-04-30 David S. Miller + * sysdeps/sparc/fpu/fenv_private.h (HAVE_RM_CTX): Define. + (libc_feholdexcept_setround_sparc_ctx): New function. + (libc_fesetenv_sparc_ctx): Likewise. + (libc_feupdateenv_sparc_ctx): Likewise. + (libc_feholdsetround_sparc_ctx): Likewise. + (libc_feholdexcept_setround_ctx): Define. + (libc_feholdexcept_setroundf_ctx): Likewise. + (libc_feholdexcept_setroundl_ctx): Likewise. + (libc_fesetenv_ctx): Likewise. + (libc_fesetenvf_ctx): Likewise. + (libc_fesetenvl_ctx): Likewise. + (libc_feupdateenv_ctx): Likewise. + (libc_feupdateenvf_ctx): Likewise. + (libc_feupdateenvl_ctx): Likewise. + (libc_feresetround_ctx): Likewise. + (libc_feresetroundf_ctx): Likewise. + (libc_feresetroundl_ctx): Likewise. + (libc_feholdsetround_ctx): Likewise. + (libc_feholdsetroundf_ctx): Likewise. + (libc_feholdsetroundl_ctx): Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/siginfo.h (EMT_TAGOVF): Protect with __USE_GNU instead of XOPEN cpp guards. diff --git a/sysdeps/sparc/fpu/fenv_private.h b/sysdeps/sparc/fpu/fenv_private.h index 8690879..29b5d12 100644 --- a/sysdeps/sparc/fpu/fenv_private.h +++ b/sysdeps/sparc/fpu/fenv_private.h @@ -115,4 +115,68 @@ libc_feresetround (fenv_t *e) #define libc_feholdsetroundl libc_feholdsetround #define libc_feresetroundl libc_feresetround +/* We have support for rounding mode context. */ +#define HAVE_RM_CTX 1 + +static __always_inline void +libc_feholdexcept_setround_sparc_ctx (struct rm_ctx *ctx, int round) +{ + fenv_t new; + + __fenv_stfsr(ctx->env); + new = ctx->env & ~((0x1f << 23) | FE_ALL_EXCEPT); + new = (new & ~__FE_ROUND_MASK) | round; + if (__glibc_unlikely (new != ctx->env)) + { + __fenv_ldfsr(new); + ctx->updated_status = true; + } + else + ctx->updated_status = false; +} + +static __always_inline void +libc_fesetenv_sparc_ctx (struct rm_ctx *ctx) +{ + libc_fesetenv(&ctx->env); +} + +static __always_inline void +libc_feupdateenv_sparc_ctx (struct rm_ctx *ctx) +{ + if (__glibc_unlikely (ctx->updated_status)) + libc_feupdateenv_test (&ctx->env, 0); +} + +static __always_inline void +libc_feholdsetround_sparc_ctx (struct rm_ctx *ctx, int round) +{ + fenv_t new; + + __fenv_stfsr(ctx->env); + new = (ctx->env & ~__FE_ROUND_MASK) | round; + if (__glibc_unlikely (new != ctx->env)) + { + __fenv_ldfsr(new); + ctx->updated_status = true; + } + else + ctx->updated_status = false; +} +#define libc_feholdexcept_setround_ctx libc_feholdexcept_setround_sparc_ctx +#define libc_feholdexcept_setroundf_ctx libc_feholdexcept_setround_sparc_ctx +#define libc_feholdexcept_setroundl_ctx libc_feholdexcept_setround_sparc_ctx +#define libc_fesetenv_ctx libc_fesetenv_sparc_ctx +#define libc_fesetenvf_ctx libc_fesetenv_sparc_ctx +#define libc_fesetenvl_ctx libc_fesetenv_sparc_ctx +#define libc_feupdateenv_ctx libc_feupdateenv_sparc_ctx +#define libc_feupdateenvf_ctx libc_feupdateenv_sparc_ctx +#define libc_feupdateenvl_ctx libc_feupdateenv_sparc_ctx +#define libc_feresetround_ctx libc_feupdateenv_sparc_ctx +#define libc_feresetroundf_ctx libc_feupdateenv_sparc_ctx +#define libc_feresetroundl_ctx libc_feupdateenv_sparc_ctx +#define libc_feholdsetround_ctx libc_feholdsetround_sparc_ctx +#define libc_feholdsetroundf_ctx libc_feholdsetround_sparc_ctx +#define libc_feholdsetroundl_ctx libc_feholdsetround_sparc_ctx + #endif /* FENV_PRIVATE_H */