From 54fa2475d37b9c7afd903eb970362e50ec76f01e Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Mon, 31 Mar 2014 14:56:37 +0000 Subject: 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 . (__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. --- math/w_atan2f.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'math/w_atan2f.c') diff --git a/math/w_atan2f.c b/math/w_atan2f.c index 6967540e69..e4e90fc72a 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) -- cgit 1.4.1