diff options
author | Joseph Myers <joseph@codesourcery.com> | 2014-03-31 14:56:37 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2014-03-31 14:56:37 +0000 |
commit | 54fa2475d37b9c7afd903eb970362e50ec76f01e (patch) | |
tree | 7edfc5402ad7ae934fb27a9b132aaa7950d92262 /math/w_atan2l.c | |
parent | 757d9dd5c3efa56fac75965abc014faaae7b7895 (diff) | |
download | glibc-54fa2475d37b9c7afd903eb970362e50ec76f01e.zip glibc-54fa2475d37b9c7afd903eb970362e50ec76f01e.tar.gz glibc-54fa2475d37b9c7afd903eb970362e50ec76f01e.tar.bz2 |
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.
Diffstat (limited to 'math/w_atan2l.c')
-rw-r--r-- | math/w_atan2l.c | 8 |
1 files changed, 7 insertions, 1 deletions
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 <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) |