This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Committed] Fix MPFR issues in fortran/arith.c and fortran/simplify.c


I've tested and committed the following patch to work around
issues with the use of mpfr functions that either appeared 
first in mpfr-2.2.0 or were fixed in this version.

2006-09-28  Steven G. Kargl <kargl@gcc.gnu.org>

	* arith.c: Change conditional test for inclusion of arctangent().
	(gfc_check_real_range): Change conditional test for use of
	mpfr_subnormalize.
	* simplify.c (gfc_simplify_atan2): Fix conditional for use of
	mpfr_atan2() instead of arctangent().
	(gfc_simplify_exponent): Fix conditional for use of mpfr_get_exp().
 	(gfc_simplify_log): Fix conditional for use of mpfr_atan2() instead
	 of arctangent().
	(gfc_simplify_nearest): Fix conditional for use of mpfr_nextafter(). 

-- 
Steve

Index: arith.c
===================================================================
--- arith.c	(revision 117257)
+++ arith.c	(working copy)
@@ -75,7 +75,7 @@ gfc_set_model (mpfr_t x)
   mpfr_set_default_prec (mpfr_get_prec (x));
 }
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
 /* Calculate atan2 (y, x)
 
 atan2(y, x) = atan(y/x)				if x > 0,
@@ -408,7 +408,7 @@ gfc_check_real_range (mpfr_t p, int kind
     }
   else if (mpfr_cmp (q, gfc_real_kinds[i].tiny) < 0)
     {
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
       /* MPFR operates on a number with a given precision and enormous
 	exponential range.  To represent subnormal numbers, the exponent is
 	allowed to become smaller than emin, but always retains the full
Index: simplify.c
===================================================================
--- simplify.c	(revision 117257)
+++ simplify.c	(working copy)
@@ -607,7 +607,7 @@ gfc_simplify_atan2 (gfc_expr * y, gfc_ex
       return &gfc_bad_expr;
     }
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
   arctangent2 (y->value.real, x->value.real, result->value.real);
 #else
   mpfr_atan2 (result->value.real, y->value.real, x->value.real, GFC_RND_MODE);
@@ -1060,7 +1060,7 @@ gfc_simplify_exponent (gfc_expr * x)
   int i;
   gfc_expr *result;
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
   mpfr_t tmp;
 #endif
 
@@ -1078,7 +1078,7 @@ gfc_simplify_exponent (gfc_expr * x)
       return result;
     }
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
   /* PR fortran/28276 suffers from a buggy MPFR, and this block of code
      does not function correctly.  */
   mpfr_init (tmp);
@@ -2161,7 +2161,7 @@ gfc_simplify_log (gfc_expr * x)
       mpfr_init (xr);
       mpfr_init (xi);
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
       arctangent2 (x->value.complex.i, x->value.complex.r, result->value.complex.i);
 #else
       mpfr_atan2 (result->value.complex.i, x->value.complex.i, x->value.complex.r,
@@ -2495,7 +2495,7 @@ gfc_simplify_nearest (gfc_expr * x, gfc_
   gfc_expr *result;
   mpfr_t tmp;
   int sgn;
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
   int direction;
 #else
   mp_exp_t emin, emax;
@@ -2513,7 +2513,7 @@ gfc_simplify_nearest (gfc_expr * x, gfc_
   gfc_set_model_kind (x->ts.kind);
   result = gfc_copy_expr (x);
 
-#if !defined(MPFR_VERSION_MAJOR)
+#if MPFR_VERSION_MAJOR < 2 || (MPFR_VERSION_MAJOR == 2 && MPFR_VERSION_MINOR < 2)
 
   direction = mpfr_sgn (s->value.real);
   sgn = mpfr_sgn (x->value.real);


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