This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Set up errno properly for yn


On Wed, May 09, 2012 at 05:13:16PM +0000, Joseph S. Myers wrote:
> I'd expect all versions of this function to need similar changes.  
> Conditioning the test on TEST_DOUBLE certainly seems wrong.

I'm sorry this reply has taken so long.  I didn't mean to let this
drop off,  but I've been away, sick, etc.

This is what I have right now.  But it still isn't applicable, I'm
afraid, because I had to guard the errno test with #ifndef TEST_LDOUBLE.
If I don't do this, I get failures:

testing long double (without inline functions)
Failure: yn (10, min_value) == -inf: Exception "Invalid operation" set
Failure: Test: yn (10, min_value) == -inf
Result:
 is:         -nan  -nan
 should be:  -inf  -inf

testing long double (inline functions)
Failure: Test: yn (10, min_value) == -inf
Result:
 is:         -nan  -nan
 should be:  -inf  -inf

And I unfortunately haven't investigated yet why that happens...
Any ideas?  Thanks,

--- libc/math/libm-test.inc.mp	2012-05-27 19:40:22.878913479 +0200
+++ libc/math/libm-test.inc	2012-05-28 00:40:19.445667133 +0200
@@ -8548,8 +8548,13 @@ yn_test (void)
   TEST_ff_f (yn, 10, 2.0, -129184.542208039282635913145923304214L);
   TEST_ff_f (yn, 10, 10.0, -0.359814152183402722051986577343560609L);
 
-  END (yn);
+#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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]