This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Set up errno properly for yn
On Sun, May 27, 2012 at 11:28:29PM +0000, Joseph S. Myers wrote:
> * You've found a separate bug in the course of fixing a bug. So file it
> in Bugzilla so people can find it there as a known bug.
I've filed http://sourceware.org/bugzilla/show_bug.cgi?id=14173
> * When adding a test that's disabled for TEST_LDOUBLE because of that
> separate bug, include a comment by the disabling that references "bug
> NNNNN" for whatever the number is, so it's easy to find and removing the
> disabling when the separate bug is fixed.
Done. Ok for trunk now? Regtested on x86_64-linux. Thanks,
2012-05-28 Marek Polacek <polacek@redhat.com>
[BZ #6808]
* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_yn): Set errno to
ERANGE when the result is +-Inf.
* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise.
* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_ynl): Likewise.
* math/libm-test.inc (yn_test): Add another test.
--- libc/math/libm-test.inc.mp 2012-05-27 19:40:22.878913479 +0200
+++ libc/math/libm-test.inc 2012-05-28 02:09:44.960435309 +0200
@@ -8548,8 +8548,14 @@ yn_test (void)
TEST_ff_f (yn, 10, 2.0, -129184.542208039282635913145923304214L);
TEST_ff_f (yn, 10, 10.0, -0.359814152183402722051986577343560609L);
- END (yn);
+ /* See Bug 14173 for why we can't test long double variant yet. */
+#ifndef TEST_LDOUBLE
+ errno = 0;
+ TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION);
+ check_int ("errno for yn(10,-min) == ERANGE", errno, ERANGE, 0, 0, 0);
+#endif
+ END (yn);
}
--- libc/sysdeps/ieee754/ldbl-96/e_jnl.c.mp 2012-05-10 15:41:13.163010573 +0200
+++ libc/sysdeps/ieee754/ldbl-96/e_jnl.c 2012-05-27 19:43:35.343410329 +0200
@@ -56,6 +56,7 @@
*
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
@@ -368,6 +369,9 @@ __ieee754_ynl (int n, long double x)
a = temp;
}
}
+ /* If B is +-Inf, set up errno accordingly. */
+ if (! __finitel (b))
+ __set_errno (ERANGE);
if (sign > 0)
return b;
else
--- libc/sysdeps/ieee754/flt-32/e_jnf.c.mp 2012-05-10 16:29:01.480632004 +0200
+++ libc/sysdeps/ieee754/flt-32/e_jnf.c 2012-05-27 19:43:35.358410367 +0200
@@ -13,6 +13,7 @@
* ====================================================
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
@@ -199,6 +200,9 @@ __ieee754_ynf(int n, float x)
GET_FLOAT_WORD(ib,b);
a = temp;
}
+ /* If B is +-Inf, set up errno accordingly. */
+ if (! __finitef (b))
+ __set_errno (ERANGE);
if(sign>0) return b; else return -b;
}
strong_alias (__ieee754_ynf, __ynf_finite)
--- libc/sysdeps/ieee754/dbl-64/e_jn.c.mp 2012-05-08 16:54:56.867427923 +0200
+++ libc/sysdeps/ieee754/dbl-64/e_jn.c 2012-05-27 19:43:35.414410513 +0200
@@ -36,6 +36,7 @@
*
*/
+#include <errno.h>
#include <math.h>
#include <math_private.h>
@@ -276,6 +277,9 @@ __ieee754_yn(int n, double x)
GET_HIGH_WORD(high,b);
a = temp;
}
+ /* If B is +-Inf, set up errno accordingly. */
+ if (! __finite (b))
+ __set_errno (ERANGE);
}
if(sign>0) return b; else return -b;
}
Marek