Set errno for atan2 underflow (bug 16349).

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.

	[BZ #16349]
	* math/w_atan2.c: Include <errno.h>.
	(__atan2): Set errno for result underflowing to zero.
	* math/w_atan2f.c: Include <errno.h>.
	(__atan2f): Set errno for result underflowing to zero.
	* math/w_atan2l.c: Include <errno.h>.
	(__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.
This commit is contained in:
Joseph Myers 2014-03-31 14:56:37 +00:00
parent 757d9dd5c3
commit 54fa2475d3
7 changed files with 581 additions and 551 deletions

View File

@ -1,3 +1,16 @@
2014-03-31 Joseph Myers <joseph@codesourcery.com>
[BZ #16349]
* math/w_atan2.c: Include <errno.h>.
(__atan2): Set errno for result underflowing to zero.
* math/w_atan2f.c: Include <errno.h>.
(__atan2f): Set errno for result underflowing to zero.
* math/w_atan2l.c: Include <errno.h>.
(__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.
2014-03-31 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
* sysdeps/powerpc/powerpc64/power8/fpu/s_finite.S (MFVSRD_R3_V1):

10
NEWS
View File

@ -9,11 +9,11 @@ Version 2.20
* The following bugs are resolved with this release:
15347, 15804, 15894, 16002, 16198, 16284, 16348, 16357, 16362, 16447,
16532, 16545, 16574, 16599, 16600, 16609, 16610, 16611, 16613, 16623,
16632, 16634, 16639, 16642, 16648, 16649, 16670, 16674, 16677, 16680,
16683, 16689, 16695, 16701, 16706, 16707, 16712, 16713, 16714, 16731,
16743, 16758, 16759, 16760, 16770.
15347, 15804, 15894, 16002, 16198, 16284, 16348, 16349, 16357, 16362,
16447, 16532, 16545, 16574, 16599, 16600, 16609, 16610, 16611, 16613,
16623, 16632, 16634, 16639, 16642, 16648, 16649, 16670, 16674, 16677,
16680, 16683, 16689, 16695, 16701, 16706, 16707, 16712, 16713, 16714,
16731, 16743, 16758, 16759, 16760, 16770.
* Running the testsuite no longer terminates as soon as a test fails.
Instead, a file tests.sum (xtests.sum from "make xcheck") is generated,

View File

@ -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

File diff suppressed because it is too large Load Diff

View File

@ -20,6 +20,7 @@
* wrapper atan2(y,x)
*/
#include <errno.h>
#include <math.h>
#include <math_private.h>
@ -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

View File

@ -20,6 +20,7 @@
* wrapper atan2f(y,x)
*/
#include <errno.h>
#include <math.h>
#include <math_private.h>
@ -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)

View File

@ -20,6 +20,7 @@
* wrapper atan2l(y,x)
*/
#include <errno.h>
#include <math.h>
#include <math_private.h>
@ -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)