From patchwork Tue Mar 11 22:33:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 44 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx22.g.dreamhost.com (caibbdcaabij.dreamhost.com [208.113.200.189]) by wilcox.dreamhost.com (Postfix) with ESMTP id 44BA2360108 for ; Tue, 11 Mar 2014 15:34:06 -0700 (PDT) Received: by homiemail-mx22.g.dreamhost.com (Postfix, from userid 14307373) id E676C4D96929; Tue, 11 Mar 2014 15:34:05 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx22.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-mx22.g.dreamhost.com (Postfix) with ESMTPS id C6F214D96923 for ; Tue, 11 Mar 2014 15:34:05 -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:from:to:cc:subject:message-id :mime-version:content-type; q=dns; s=default; b=ks2CNRGdBOSyms6P +TeB4gMca4RsXBflShZcikS9XSZFO1bogSl5+zfSFH93rJNIlZ+b+4HDr4Dgx8W5 ANQoSxSiOrjUl7n3bhBVO8KZsjatwmZHL99M2U2kiD/vuN1Ww7+bmauYbMMmwHsh Z6DDK6pHlLWYnygdoeVcIAzBxMI= 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:from:to:cc:subject:message-id :mime-version:content-type; s=default; bh=pW4y+SsL/PanX0lEQvbrB5 80Mcs=; b=BI6+ZRUagIgmpil+a5jZ6bUCpDB5oJ5G7ZVXNfuJKDcIHKByps5ntA pGgbpm8S3LC8t5n81rrCCKXL0flsoKI/qpo/Wv1HhRqMZGub2fSo88GzNqyVECWd KF0laDb20D+PfDLE5Ke54uBHL0/dpL7RFgb10iz0uWjDFV4phOVak= Received: (qmail 28556 invoked by alias); 11 Mar 2014 22:34:03 -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 28545 invoked by uid 89); 11 Mar 2014 22:34:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.6 required=5.0 tests=AWL, BAYES_50 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Tue, 11 Mar 2014 22:33:53 +0000 From: "Joseph S. Myers" To: CC: Steve Ellcey Subject: Fix MIPS libc_feresetround*_ctx to preserve exceptions Message-ID: MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in Testing on mips64 showed missing underflow exceptions (from exp, for example) in non-default rounding modes, caused by libc_feresetround*_ctx wrongly restoring a saved environment without preserving exceptions, when that's only valid for the _noex variants. (I don't know why Steve didn't see this in his testing.) This patch fixes this by using libc_feupdateenv_mips_ctx for the relevant macros and removing the problem definitions. The problem definitions aren't suitable for the _noex macros either because they only discard exceptions in non-default rounding modes, and while for some uses of *_noex/*_NOEX it doesn't matter whether exceptions are discarded, dbl-64/e_remainder.c requires SET_RESTORE_ROUND_NOEX to cause exceptions to be discarded. I think the accumulated set of macros / functions for optimized exception / rounding mode handling could do with a careful review by now, and possible refactoring, and at least one new feature (extracting the saved rounding mode from an environment / context variable - see dbl-64/e_sqrt.c for a case where this could be used). Tested mips64 and committed. (No Bugzilla bug because the problem postdates the last release.) 2014-03-11 Joseph Myers * sysdeps/mips/math_private.h [__mips_hard_float] (libc_feresetround_ctx): Define to libc_feupdateenv_mips_ctx not libc_feresetround_mips_ctx. [__mips_hard_float] (libc_feresetroundf_ctx): Likewise. [__mips_hard_float] (libc_feresetroundl_ctx): Likewise. [__mips_hard_float] (libc_feresetround_mips_ctx): Remove. diff --git a/sysdeps/mips/math_private.h b/sysdeps/mips/math_private.h index edf6047..7f2cdf5 100644 --- a/sysdeps/mips/math_private.h +++ b/sysdeps/mips/math_private.h @@ -217,6 +217,9 @@ libc_feupdateenv_mips_ctx (struct rm_ctx *ctx) # define libc_feupdateenv_ctx libc_feupdateenv_mips_ctx # define libc_feupdateenvf_ctx libc_feupdateenv_mips_ctx # define libc_feupdateenvl_ctx libc_feupdateenv_mips_ctx +# define libc_feresetround_ctx libc_feupdateenv_mips_ctx +# define libc_feresetroundf_ctx libc_feupdateenv_mips_ctx +# define libc_feresetroundl_ctx libc_feupdateenv_mips_ctx static __always_inline void libc_feholdsetround_mips_ctx (struct rm_ctx *ctx, int round) @@ -242,16 +245,6 @@ libc_feholdsetround_mips_ctx (struct rm_ctx *ctx, int round) # define libc_feholdsetroundf_ctx libc_feholdsetround_mips_ctx # define libc_feholdsetroundl_ctx libc_feholdsetround_mips_ctx -static __always_inline void -libc_feresetround_mips_ctx (struct rm_ctx *ctx) -{ - if (__glibc_unlikely (ctx->updated_status)) - _FPU_SETCW (ctx->env); -} -# define libc_feresetround_ctx libc_feresetround_mips_ctx -# define libc_feresetroundf_ctx libc_feresetround_mips_ctx -# define libc_feresetroundl_ctx libc_feresetround_mips_ctx - #endif #include_next