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]

[MPC PATCH INSTALLED]: Use mpc_realref/mpc_imagref instead of MPC_RE/MPC_IM


The MPC manual deprecates MPC_RE/MPC_IM in favor of the documented
mpc_realref/mpc_imagref interfaces.  (These macros access the individual
real/imaginary bits of an MPC structure.)  In the current MPC svn repo,
they have moved the deprecated macros to an internal-only header.  So
user-code must utilize the supported style which works in both the current
and future MPC releases.

In anticipation of the forthcoming MPC release, I've updated the GCC
sources accordingly.  This is a straight "search-and-replace".

Tested on mainline with and without MPC.  No regressions.

Installed as "obvious".

		--Kaveh


2009-06-05  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (do_mpc_ckconv, do_mpc_arg1): Use
	mpc_realref/mpc_imagref instead of MPC_RE/MPC_IM.

fortran:
	* simplify.c (call_mpc_func): Use mpc_realref/mpc_imagref
	instead of MPC_RE/MPC_IM.

diff -rup orig/egcc-SVN20090604/gcc/builtins.c egcc-SVN20090604/gcc/builtins.c
--- orig/egcc-SVN20090604/gcc/builtins.c	2009-05-30 02:00:46.000000000 +0200
+++ egcc-SVN20090604/gcc/builtins.c	2009-06-05 02:42:01.000000000 +0200
@@ -13216,21 +13216,21 @@ do_mpc_ckconv (mpc_srcptr m, tree type,
   /* Proceed iff we get a normal number, i.e. not NaN or Inf and no
      overflow/underflow occurred.  If -frounding-math, proceed iff the
      result of calling FUNC was exact.  */
-  if (mpfr_number_p (MPC_RE (m)) && mpfr_number_p (MPC_IM (m))
+  if (mpfr_number_p (mpc_realref (m)) && mpfr_number_p (mpc_imagref (m))
       && !mpfr_overflow_p () && !mpfr_underflow_p ()
       && (!flag_rounding_math || !inexact))
     {
       REAL_VALUE_TYPE re, im;

-      real_from_mpfr (&re, MPC_RE (m), type, GMP_RNDN);
-      real_from_mpfr (&im, MPC_IM (m), type, GMP_RNDN);
+      real_from_mpfr (&re, mpc_realref (m), type, GMP_RNDN);
+      real_from_mpfr (&im, mpc_imagref (m), type, GMP_RNDN);
       /* Proceed iff GCC's REAL_VALUE_TYPE can hold the MPFR values,
 	 check for overflow/underflow.  If the REAL_VALUE_TYPE is zero
 	 but the mpft_t is not, then we underflowed in the
 	 conversion.  */
       if (real_isfinite (&re) && real_isfinite (&im)
-	  && (re.cl == rvc_zero) == (mpfr_zero_p (MPC_RE (m)) != 0)
-	  && (im.cl == rvc_zero) == (mpfr_zero_p (MPC_IM (m)) != 0))
+	  && (re.cl == rvc_zero) == (mpfr_zero_p (mpc_realref (m)) != 0)
+	  && (im.cl == rvc_zero) == (mpfr_zero_p (mpc_imagref (m)) != 0))
         {
 	  REAL_VALUE_TYPE re_mode, im_mode;

@@ -13676,8 +13676,8 @@ do_mpc_arg1 (tree arg, tree type, int (*
 	  mpc_t m;

 	  mpc_init2 (m, prec);
-	  mpfr_from_real (MPC_RE(m), re, rnd);
-	  mpfr_from_real (MPC_IM(m), im, rnd);
+	  mpfr_from_real (mpc_realref(m), re, rnd);
+	  mpfr_from_real (mpc_imagref(m), im, rnd);
 	  mpfr_clear_flags ();
 	  inexact = func (m, m, crnd);
 	  result = do_mpc_ckconv (m, type, inexact);
diff -rup orig/egcc-SVN20090604/gcc/fortran/simplify.c egcc-SVN20090604/gcc/fortran/simplify.c
--- orig/egcc-SVN20090604/gcc/fortran/simplify.c	2009-05-30 02:00:45.000000000 +0200
+++ egcc-SVN20090604/gcc/fortran/simplify.c	2009-06-05 02:42:26.000000000 +0200
@@ -223,8 +223,8 @@ call_mpc_func (mpfr_ptr result_re, mpfr_
   mpc_init2 (c, mpfr_get_default_prec());
   mpc_set_fr_fr (c, input_re, input_im, GFC_MPC_RND_MODE);
   func (c, c, GFC_MPC_RND_MODE);
-  mpfr_set (result_re, MPC_RE (c), GFC_RND_MODE);
-  mpfr_set (result_im, MPC_IM (c), GFC_RND_MODE);
+  mpfr_set (result_re, mpc_realref (c), GFC_RND_MODE);
+  mpfr_set (result_im, mpc_imagref (c), GFC_RND_MODE);
   mpc_clear (c);
 }
 #endif


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