diff mbox

Go patch committed: Provide matherr function

Message ID mcrobt7o70i.fsf@dhcp-172-18-216-180.mtv.corp.google.com
State New
Headers show

Commit Message

Ian Lance Taylor Feb. 10, 2012, 12:40 a.m. UTC
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> I could give it a try once the current bootstraps are finished.  For the
> moment I've shamelessly adapted the following from the __GNUC__ section
> of Solaris 11 <iso/math_c99.h>:

I committed this patch which ought to work.

Bootstrapped and ran Go testsuite on i386-pc-solaris2.11.

Ian
diff mbox

Patch

Index: libgo/runtime/go-matherr.c
===================================================================
--- libgo/runtime/go-matherr.c	(revision 184024)
+++ libgo/runtime/go-matherr.c	(working copy)
@@ -35,7 +35,7 @@  matherr (struct exception* e)
   n = e->name;
   if (__builtin_strcmp (n, "acos") == 0
       || __builtin_strcmp (n, "asin") == 0)
-    e->retval = NAN;
+    e->retval = __builtin_nan ("");
   else if (__builtin_strcmp (n, "atan2") == 0)
     {
       if (e->arg1 == 0 && e->arg2 == 0)
@@ -53,11 +53,11 @@  matherr (struct exception* e)
     }
   else if (__builtin_strcmp (n, "log") == 0
 	   || __builtin_strcmp (n, "log10") == 0)
-    e->retval = NAN;
+    e->retval = __builtin_nan ("");
   else if (__builtin_strcmp (n, "pow") == 0)
     {
       if (e->arg1 < 0)
-	e->retval = NAN;
+	e->retval = __builtin_nan ("");
       else if (e->arg1 == 0 && e->arg2 == 0)
 	e->retval = 1.0;
       else if (e->arg1 == 0 && e->arg2 < 0)
@@ -65,9 +65,9 @@  matherr (struct exception* e)
 	  double i;
 
 	  if (modf (e->arg2, &i) == 0 && ((int64_t) i & 1) == 1)
-	    e->retval = copysign (INFINITY, e->arg1);
+	    e->retval = copysign (__builtin_inf (), e->arg1);
 	  else
-	    e->retval = INFINITY;
+	    e->retval = __builtin_inf ();
 	}
       else
 	return 0;
@@ -75,7 +75,7 @@  matherr (struct exception* e)
   else if (__builtin_strcmp (n, "sqrt") == 0)
     {
       if (e->arg1 < 0)
-	e->retval = NAN;
+	e->retval = __builtin_nan ("");
       else
 	return 0;
     }