From patchwork Tue Mar 25 16:07:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 273 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx23.g.dreamhost.com (caibbdcaabja.dreamhost.com [208.113.200.190]) by wilcox.dreamhost.com (Postfix) with ESMTP id CCEE03600A9 for ; Tue, 25 Mar 2014 09:08:09 -0700 (PDT) Received: by homiemail-mx23.g.dreamhost.com (Postfix, from userid 14307373) id 83F99637B7F1F; Tue, 25 Mar 2014 09:08:09 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx23.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-mx23.g.dreamhost.com (Postfix) with ESMTPS id 627B96366F0E3 for ; Tue, 25 Mar 2014 09:08:09 -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:subject:message-id:mime-version :content-type; q=dns; s=default; b=FlGig/X0UIjJ8PBWGIsnYyZMJZ2BK 6hKxZTxUSO3jXKLfk5fikOGxeIm1UEhA1pQd+zhwo1yr+TdBtRCbU6SySKzgmd2m 7/HWgTS6RQC4PyZGWWuJqeTE2pWvxmmkkgdcjOe46IBEQ2QFwNykZZLbRifpy9q+ 7DoX4tc6dHP8Ew= 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:subject:message-id:mime-version :content-type; s=default; bh=3uwhHzR/IlGRJ3S0pVDcUg84ibw=; b=Jj/ DHSpw/wpEAJxTuIWuxBYhHqMzNfah10jX4+5G8Yj/L85aJWP4V9u/DheQ1KCqRQC LtqXvCOeMsuxIzOwmQ74HJ0ibm6A+mP6UKlZZRefgI2bkwJG4/3N1OSwlyAHH8WU 0y7T/mIfR1sMlOX65XAaBLwdJ7gwp6Pmxjrozb/Q= Received: (qmail 3067 invoked by alias); 25 Mar 2014 16:08:07 -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 3055 invoked by uid 89); 25 Mar 2014 16:08:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Tue, 25 Mar 2014 16:07:40 +0000 From: "Joseph S. Myers" To: Subject: Set errno for atan2 underflow (bug 16349) Message-ID: MIME-Version: 1.0 X-DH-Original-To: glibc@patchwork.siddhesh.in This patch fixes bug 16349, missing errno setting for atan2 underflow, by adding appropriate checks to the existing wrappers. (As in other cases, the __kernel_standard support for calling matherr is considered to be for existing code expecting existing rules for what's considered an error, even if those don't correspond to a general logical scheme for what counts as what kind of error, so __set_errno calls are added directly without any changes to __kernel_standard.) Tested x86_64 and x86. (auto-libm-test-out diffs omitted below.) 2014-03-25 Joseph Myers [BZ #16349] * math/w_atan2.c: Include . (__atan2): Set errno for result underflowing to zero. * math/w_atan2f.c: Include . (__atan2f): Set errno for result underflowing to zero. * math/w_atan2l.c: Include . (__atan2l): Set errno for result underflowing to zero. * math/auto-libm-test-in: Don't allow missing errno for some atan2 tests. * math/auto-libm-test-out: Regenerated. diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index 7c80192..7ef6b81 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -157,13 +157,12 @@ atan2 -min -max atan2 min_subnorm -max atan2 -min_subnorm -max # Bug 15319: underflow exception may be missing. -# Bug 16349: errno setting may be missing. atan2 1 max missing-underflow atan2 -1 max missing-underflow -atan2 min max missing-underflow missing-errno -atan2 -min max missing-underflow missing-errno -atan2 min_subnorm max missing-underflow missing-errno -atan2 -min_subnorm max missing-underflow missing-errno +atan2 min max missing-underflow +atan2 -min max missing-underflow +atan2 min_subnorm max missing-underflow +atan2 -min_subnorm max missing-underflow atanh 0 atanh -0 diff --git a/math/w_atan2.c b/math/w_atan2.c index efbf0b3..c56d7b6 100644 --- a/math/w_atan2.c +++ b/math/w_atan2.c @@ -20,6 +20,7 @@ * wrapper atan2(y,x) */ +#include #include #include @@ -27,10 +28,15 @@ double __atan2 (double y, double x) { + double z; + if (__builtin_expect (x == 0.0 && y == 0.0, 0) && _LIB_VERSION == _SVID_) return __kernel_standard (y, x, 3); /* atan2(+-0,+-0) */ - return __ieee754_atan2 (y, x); + z = __ieee754_atan2 (y, x); + if (__glibc_unlikely (z == 0.0 && y != 0.0 && __finite (x))) + __set_errno (ERANGE); + return z; } weak_alias (__atan2, atan2) #ifdef NO_LONG_DOUBLE diff --git a/math/w_atan2f.c b/math/w_atan2f.c index 6967540..e4e90fc 100644 --- a/math/w_atan2f.c +++ b/math/w_atan2f.c @@ -20,6 +20,7 @@ * wrapper atan2f(y,x) */ +#include #include #include @@ -27,9 +28,14 @@ float __atan2f (float y, float x) { + float z; + if (__builtin_expect (x == 0.0f && y == 0.0f, 0) && _LIB_VERSION == _SVID_) return __kernel_standard_f (y, x, 103); /* atan2(+-0,+-0) */ - return __ieee754_atan2f (y, x); + z = __ieee754_atan2f (y, x); + if (__glibc_unlikely (z == 0.0f && y != 0.0f && __finitef (x))) + __set_errno (ERANGE); + return z; } weak_alias (__atan2f, atan2f) diff --git a/math/w_atan2l.c b/math/w_atan2l.c index f1de1d1..d6498ae 100644 --- a/math/w_atan2l.c +++ b/math/w_atan2l.c @@ -20,6 +20,7 @@ * wrapper atan2l(y,x) */ +#include #include #include @@ -27,9 +28,14 @@ long double __atan2l (long double y, long double x) { + long double z; + if (__builtin_expect (x == 0.0L && y == 0.0L, 0) && _LIB_VERSION == _SVID_) return __kernel_standard_l (y, x, 203); /* atan2(+-0,+-0) */ - return __ieee754_atan2l (y, x); + z = __ieee754_atan2l (y, x); + if (__glibc_unlikely (z == 0.0L && y != 0.0L && __finitel (x))) + __set_errno (ERANGE); + return z; } weak_alias (__atan2l, atan2l)