From patchwork Thu Apr 17 08:20:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcus Shawcroft X-Patchwork-Id: 339812 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 8B43F140080 for ; Thu, 17 Apr 2014 18:22:54 +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:cc:subject:date:message-id :content-type:content-transfer-encoding; q=dns; s=default; b=Kzs hxQdJtLH68OQpozFwDzevFKpe2YKvsglwXxz2jgVPwvXZb+3TExOE3SUxNa4AhDT sqi62vKbOBCih7mR17Ll9qzWUYv1ZAv4BepLak8UfIYO+xEge73PlKk54Afv+i00 Gx/EJ91/ceIsctq+QiTqfRsNnVEJXNpLcOYC/pS8= 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:cc:subject:date:message-id :content-type:content-transfer-encoding; s=default; bh=4iX07fXyA uQncLLgQvNdaAyP9sI=; b=gCNSSzs2b5bOL19iqYeEk5QESYRo1v/WlI2fzTeFh SjDUIlfaaNye4Q0cR5qXXHiRygXXUhfZw5BMbaE2xPJoDJLmR/d8S199CKKH3O46 ugAQO0luPBuo4CnOVCMkkuCPU2Mb9mWUfYxZ6IRcr9WD+em9Vg6vEe7QeBaZ5Dab 0g= Received: (qmail 9499 invoked by alias); 17 Apr 2014 08:20:35 -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 9420 invoked by uid 89); 17 Apr 2014 08:20:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 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: Marcus Shawcroft To: libc-alpha@sourceware.org Cc: Marcus Shawcroft Subject: [COMMITTED][AArch64] Define HAVE_RM_CTX and related hooks. Date: Thu, 17 Apr 2014 09:20:19 +0100 Message-Id: <1397722819-27264-1-git-send-email-marcus.shawcroft@arm.com> X-MC-Unique: 114041709202901201 Hi, The attached patch by Wilco and Ian B @ARM provides a definition of HAVE_RM_CTX and related hooks for AArch64. Cheers /Marcus --- ChangeLog | 12 ++++++++ sysdeps/aarch64/fpu/math_private.h | 55 ++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2bbd47a..ac40659 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-04-17 Ian Bolton + Wilco Dijkstra + + * sysdeps/aarch64/fpu/math_private.h (HAVE_RM_CTX) + (libc_feholdsetround_aarch64_ctx) + (libc_feholdsetround_ctx, libc_feholdsetroundf_ctx) + (libc_feholdsetroundl_ctx, libc_feresetround_aarch64_ctx) + (libc_feresetround_ctx, libc_feresetroundf_ctx) + (libc_feresetroundl_ctx, libc_feresetround_noex_aarch64_ctx) + (libc_feresetround_noex_ctx, libc_feresetround_noexf_ctx) + (libc_feresetround_noexl_ctx): Define. + 2014-04-16 Richard Henderson * sysdeps/unix/sysv/linux/alpha/nptl/pthread_once.c: Remove. diff --git a/sysdeps/aarch64/fpu/math_private.h b/sysdeps/aarch64/fpu/math_private.h index dbf203d..7424952 100644 --- a/sysdeps/aarch64/fpu/math_private.h +++ b/sysdeps/aarch64/fpu/math_private.h @@ -209,6 +209,61 @@ libc_feresetround_aarch64 (fenv_t *envp) #define libc_feresetroundf libc_feresetround_aarch64 #define libc_feresetroundl libc_feresetround_aarch64 +/* We have support for rounding mode context. */ +#define HAVE_RM_CTX 1 + +static __always_inline void +libc_feholdsetround_aarch64_ctx (struct rm_ctx *ctx, int r) +{ + fpu_control_t fpcr, fpsr, round; + + _FPU_GETCW (fpcr); + _FPU_GETFPSR (fpsr); + ctx->env.__fpsr = fpsr; + + /* Check whether rounding modes are different. */ + round = (fpcr ^ r) & FE_TOWARDZERO; + ctx->updated_status = round != 0; + + /* Set the rounding mode if changed. */ + if (__glibc_unlikely (round != 0)) + { + ctx->env.__fpcr = fpcr; + _FPU_SETCW (fpcr ^ round); + } +} + +#define libc_feholdsetround_ctx libc_feholdsetround_aarch64_ctx +#define libc_feholdsetroundf_ctx libc_feholdsetround_aarch64_ctx +#define libc_feholdsetroundl_ctx libc_feholdsetround_aarch64_ctx + +static __always_inline void +libc_feresetround_aarch64_ctx (struct rm_ctx *ctx) +{ + /* Restore the rounding mode if updated. */ + if (__glibc_unlikely (ctx->updated_status)) + _FPU_SETCW (ctx->env.__fpcr); +} + +#define libc_feresetround_ctx libc_feresetround_aarch64_ctx +#define libc_feresetroundf_ctx libc_feresetround_aarch64_ctx +#define libc_feresetroundl_ctx libc_feresetround_aarch64_ctx + +static __always_inline void +libc_feresetround_noex_aarch64_ctx (struct rm_ctx *ctx) +{ + /* Restore the rounding mode if updated. */ + if (__glibc_unlikely (ctx->updated_status)) + _FPU_SETCW (ctx->env.__fpcr); + + /* Write new FPSR to restore exception flags. */ + _FPU_SETFPSR (ctx->env.__fpsr); +} + +#define libc_feresetround_noex_ctx libc_feresetround_noex_aarch64_ctx +#define libc_feresetround_noexf_ctx libc_feresetround_noex_aarch64_ctx +#define libc_feresetround_noexl_ctx libc_feresetround_noex_aarch64_ctx + #include_next #endif