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 Tue, Jun 12, 2012 at 02:53:17PM +0200, Andreas Jaeger wrote:
> Marek, can you make that change, test and submit again?

Here it finally is.  So far tested only x86_64 and i?86...

2012-07-19  Marek Polacek  <polacek@redhat.com>

	* math/libm-test.inc (yn_test): Add another test.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c (__ieee754_ynl): Set errno
	to ERANGE when the result is +-Inf.
	* sysdeps/ieee754/ldbl-96/e_jnl.c (__ieee754_ynl): Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c (__ieee754_ynf): Likewise.
	* sysdeps/ieee754/ldbl-128/e_jnl.c (__ieee754_ynl): Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c (__ieee754_yn): Likewise.

--- libc/math/libm-test.inc.mp	2012-07-18 20:19:37.226368024 +0200
+++ libc/math/libm-test.inc	2012-07-19 19:58:06.445411858 +0200
@@ -9019,6 +9019,10 @@ yn_test (void)
      and FLT_MIN.  See Bug 14173.  */
   TEST_ff_f (yn, 10, min_value, minus_infty, OVERFLOW_EXCEPTION);
 
+  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);
+
   END (yn);
 }
 
--- libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c.mp	2012-07-19 19:51:16.705288069 +0200
+++ libc/sysdeps/ieee754/ldbl-128ibm/e_jnl.c	2012-07-19 19:59:09.159583865 +0200
@@ -56,6 +56,7 @@
  *
  */
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -387,6 +388,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/ldbl-96/e_jnl.c.mp	2012-07-18 20:20:00.279434113 +0200
+++ libc/sysdeps/ieee754/ldbl-96/e_jnl.c	2012-07-19 19:54:27.874812387 +0200
@@ -56,6 +56,7 @@
  *
  */
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -369,6 +370,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-07-18 20:20:09.013459155 +0200
+++ libc/sysdeps/ieee754/flt-32/e_jnf.c	2012-07-19 19:54:27.874812387 +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/ldbl-128/e_jnl.c.mp	2012-07-19 19:50:21.503136667 +0200
+++ libc/sysdeps/ieee754/ldbl-128/e_jnl.c	2012-07-19 19:59:25.371628331 +0200
@@ -56,6 +56,7 @@
  *
  */
 
+#include <errno.h>
 #include <math.h>
 #include <math_private.h>
 
@@ -385,6 +386,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/dbl-64/e_jn.c.mp	2012-07-18 20:20:16.856481638 +0200
+++ libc/sysdeps/ieee754/dbl-64/e_jn.c	2012-07-19 19:54:27.900812459 +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]