wok rev 9750

mpfr: add upstream patches
author Christophe Lincoln <pankso@slitaz.org>
date Wed May 11 00:48:49 2011 +0200 (2011-05-11)
parents cd5b5a4ce7a1
children 37c3bd7f4b0b
files mpfr/receipt mpfr/stuff/mpfr-3.0.0-p8.patch mpfr/stuff/mpfr-3.0.0.patch mpfr/stuff/mpfr-3.0.1.patch
line diff
     1.1 --- a/mpfr/receipt	Tue May 10 23:41:05 2011 +0200
     1.2 +++ b/mpfr/receipt	Wed May 11 00:48:49 2011 +0200
     1.3 @@ -10,13 +10,13 @@
     1.4  WGET_URL="http://www.mpfr.org/mpfr-current/$TARBALL"
     1.5  
     1.6  DEPENDS="gmp"
     1.7 -BUILD_DEPENDS="$DEPENDS gmp-dev"
     1.8 +BUILD_DEPENDS="gmp-dev"
     1.9  
    1.10  # Rules to configure and make the package.
    1.11  compile_rules()
    1.12  {	
    1.13  	cd $src
    1.14 -	patch -Np1 -i $stuff/$PACKAGE-$VERSION-$EXTRAVERSION.patch 
    1.15 +	patch -Np1 -i $stuff/$PACKAGE-$VERSION.patch 
    1.16  	./configure && make && make install
    1.17  }
    1.18  
    1.19 @@ -26,4 +26,3 @@
    1.20  	mkdir -p $fs/usr/lib
    1.21  	cp -a $_pkg/usr/lib/*.so* $fs/usr/lib
    1.22  }
    1.23 -
     2.1 --- a/mpfr/stuff/mpfr-3.0.0-p8.patch	Tue May 10 23:41:05 2011 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,1945 +0,0 @@
     2.4 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
     2.5 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:02:49.000000000 +0000
     2.6 -+++ mpfr-3.0.0-b/PATCHES	2010-06-23 11:03:36.000000000 +0000
     2.7 -@@ -0,0 +1 @@
     2.8 -+mpfr_out_str
     2.9 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
    2.10 ---- mpfr-3.0.0-a/VERSION	2010-06-10 11:00:14.000000000 +0000
    2.11 -+++ mpfr-3.0.0-b/VERSION	2010-06-23 11:03:20.000000000 +0000
    2.12 -@@ -1 +1 @@
    2.13 --3.0.0
    2.14 -+3.0.0-p1
    2.15 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
    2.16 ---- mpfr-3.0.0-a/mpfr.h	2010-06-10 11:00:14.000000000 +0000
    2.17 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-23 11:03:20.000000000 +0000
    2.18 -@@ -27,7 +27,7 @@
    2.19 - #define MPFR_VERSION_MAJOR 3
    2.20 - #define MPFR_VERSION_MINOR 0
    2.21 - #define MPFR_VERSION_PATCHLEVEL 0
    2.22 --#define MPFR_VERSION_STRING "3.0.0"
    2.23 -+#define MPFR_VERSION_STRING "3.0.0-p1"
    2.24 - 
    2.25 - /* Macros dealing with MPFR VERSION */
    2.26 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    2.27 -diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
    2.28 ---- mpfr-3.0.0-a/mpfr.texi	2010-06-10 11:00:14.000000000 +0000
    2.29 -+++ mpfr-3.0.0-b/mpfr.texi	2010-06-23 11:03:12.000000000 +0000
    2.30 -@@ -2050,7 +2050,7 @@
    2.31 - are printed. If @var{base} is greater than 10, @samp{@@} will be used
    2.32 - instead of @samp{e} as exponent delimiter.
    2.33 - 
    2.34 --Return the number of bytes written, or if an error occurred, return 0.
    2.35 -+Return the number of characters written, or if an error occurred, return 0.
    2.36 - @end deftypefun
    2.37 - 
    2.38 - @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
    2.39 -diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
    2.40 ---- mpfr-3.0.0-a/out_str.c	2010-06-10 11:00:14.000000000 +0000
    2.41 -+++ mpfr-3.0.0-b/out_str.c	2010-06-23 11:03:12.000000000 +0000
    2.42 -@@ -22,6 +22,16 @@
    2.43 - 
    2.44 - #include "mpfr-impl.h"
    2.45 - 
    2.46 -+/* Warning! S should not contain "%". */
    2.47 -+#define OUT_STR_RET(S)                          \
    2.48 -+  do                                            \
    2.49 -+    {                                           \
    2.50 -+      int r;                                    \
    2.51 -+      r = fprintf (stream, (S));                \
    2.52 -+      return r < 0 ? 0 : r;                     \
    2.53 -+    }                                           \
    2.54 -+  while (0)
    2.55 -+
    2.56 - size_t
    2.57 - mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
    2.58 -               mpfr_rnd_t rnd_mode)
    2.59 -@@ -29,6 +39,7 @@
    2.60 -   char *s, *s0;
    2.61 -   size_t l;
    2.62 -   mpfr_exp_t e;
    2.63 -+  int err;
    2.64 - 
    2.65 -   MPFR_ASSERTN (base >= 2 && base <= 62);
    2.66 - 
    2.67 -@@ -36,37 +47,16 @@
    2.68 -   if (stream == NULL)
    2.69 -     stream = stdout;
    2.70 - 
    2.71 --  if (MPFR_IS_NAN(op))
    2.72 --    {
    2.73 --      fprintf (stream, "@NaN@");
    2.74 --      return 3;
    2.75 --    }
    2.76 --
    2.77 --  if (MPFR_IS_INF(op))
    2.78 --    {
    2.79 --      if (MPFR_SIGN(op) > 0)
    2.80 --        {
    2.81 --          fprintf (stream, "@Inf@");
    2.82 --          return 3;
    2.83 --        }
    2.84 --      else
    2.85 --        {
    2.86 --          fprintf (stream, "-@Inf@");
    2.87 --          return 4;
    2.88 --        }
    2.89 --    }
    2.90 --
    2.91 --  if (MPFR_IS_ZERO(op))
    2.92 -+  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
    2.93 -     {
    2.94 --      if (MPFR_SIGN(op) > 0)
    2.95 --        {
    2.96 --          fprintf(stream, "0");
    2.97 --          return 1;
    2.98 --        }
    2.99 -+      if (MPFR_IS_NAN (op))
   2.100 -+        OUT_STR_RET ("@NaN@");
   2.101 -+      else if (MPFR_IS_INF (op))
   2.102 -+        OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
   2.103 -       else
   2.104 -         {
   2.105 --          fprintf(stream, "-0");
   2.106 --          return 2;
   2.107 -+          MPFR_ASSERTD (MPFR_IS_ZERO (op));
   2.108 -+          OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
   2.109 -         }
   2.110 -     }
   2.111 - 
   2.112 -@@ -77,21 +67,31 @@
   2.113 - 
   2.114 -   l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
   2.115 -                          - may be incorrect, as only an upper bound? */
   2.116 --  if (*s == '-')
   2.117 --    fputc (*s++, stream);
   2.118 - 
   2.119 --  /* outputs mantissa */
   2.120 --  fputc (*s++, stream); e--; /* leading digit */
   2.121 --  fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
   2.122 --  fputs (s, stream);         /* rest of mantissa */
   2.123 -+  /* outputs possible sign and significand */
   2.124 -+  err = (*s == '-' && fputc (*s++, stream) == EOF)
   2.125 -+    || fputc (*s++, stream) == EOF  /* leading digit */
   2.126 -+    || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
   2.127 -+    || fputs (s, stream) == EOF;     /* trailing significand */
   2.128 -   (*__gmp_free_func) (s0, l);
   2.129 -+  if (MPFR_UNLIKELY (err))
   2.130 -+    return 0;
   2.131 -+
   2.132 -+  e--;  /* due to the leading digit */
   2.133 - 
   2.134 -   /* outputs exponent */
   2.135 -   if (e)
   2.136 -     {
   2.137 -+      int r;
   2.138 -+
   2.139 -       MPFR_ASSERTN(e >= LONG_MIN);
   2.140 -       MPFR_ASSERTN(e <= LONG_MAX);
   2.141 --      l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   2.142 -+
   2.143 -+      r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   2.144 -+      if (MPFR_UNLIKELY (r < 0))
   2.145 -+        return 0;
   2.146 -+
   2.147 -+      l += r;
   2.148 -     }
   2.149 - 
   2.150 -   return l;
   2.151 -diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
   2.152 ---- mpfr-3.0.0-a/tests/tout_str.c	2010-06-10 11:00:13.000000000 +0000
   2.153 -+++ mpfr-3.0.0-b/tests/tout_str.c	2010-06-23 11:03:12.000000000 +0000
   2.154 -@@ -46,22 +46,54 @@
   2.155 - special (void)
   2.156 - {
   2.157 -   mpfr_t x;
   2.158 -+  unsigned int n;
   2.159 - 
   2.160 -   mpfr_init (x);
   2.161 - 
   2.162 -   mpfr_set_nan (x);
   2.163 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.164 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.165 -+  if (n != 5)
   2.166 -+    {
   2.167 -+      printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
   2.168 -+              "characters instead of 5.\n", n);
   2.169 -+      exit (1);
   2.170 -+    }
   2.171 - 
   2.172 -   mpfr_set_inf (x, 1);
   2.173 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.174 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.175 -+  if (n != 5)
   2.176 -+    {
   2.177 -+      printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
   2.178 -+               "characters instead of 5.\n", n);
   2.179 -+      exit (1);
   2.180 -+    }
   2.181 - 
   2.182 -   mpfr_set_inf (x, -1);
   2.183 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.184 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.185 -+  if (n != 6)
   2.186 -+    {
   2.187 -+      printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
   2.188 -+               "characters instead of 6.\n", n);
   2.189 -+      exit (1);
   2.190 -+    }
   2.191 - 
   2.192 -   mpfr_set_ui (x, 0, MPFR_RNDN);
   2.193 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.194 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.195 -+  if (n != 1)
   2.196 -+    {
   2.197 -+      printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
   2.198 -+               "characters instead of 1.\n", n);
   2.199 -+      exit (1);
   2.200 -+    }
   2.201 -+
   2.202 -   mpfr_neg (x, x, MPFR_RNDN);
   2.203 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.204 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   2.205 -+  if (n != 2)
   2.206 -+    {
   2.207 -+      printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
   2.208 -+               "characters instead of 2.\n", n);
   2.209 -+      exit (1);
   2.210 -+    }
   2.211 - 
   2.212 -   mpfr_clear (x);
   2.213 - }
   2.214 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   2.215 ---- mpfr-3.0.0-a/version.c	2010-06-10 11:00:14.000000000 +0000
   2.216 -+++ mpfr-3.0.0-b/version.c	2010-06-23 11:03:20.000000000 +0000
   2.217 -@@ -25,5 +25,5 @@
   2.218 - const char *
   2.219 - mpfr_get_version (void)
   2.220 - {
   2.221 --  return "3.0.0";
   2.222 -+  return "3.0.0-p1";
   2.223 - }
   2.224 -diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
   2.225 ---- mpfr-3.0.0-a/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   2.226 -+++ mpfr-3.0.0-b/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   2.227 -@@ -239,6 +239,7 @@
   2.228 - distuninstallcheck_listfiles = find . -type f -print
   2.229 - distcleancheck_listfiles = find . -type f -print
   2.230 - ACLOCAL = @ACLOCAL@
   2.231 -+ALLOCA = @ALLOCA@
   2.232 - AMTAR = @AMTAR@
   2.233 - AR = @AR@
   2.234 - AS = @AS@
   2.235 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   2.236 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:03:36.000000000 +0000
   2.237 -+++ mpfr-3.0.0-b/PATCHES	2010-06-25 13:23:13.000000000 +0000
   2.238 -@@ -0,0 +1 @@
   2.239 -+alloca
   2.240 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   2.241 ---- mpfr-3.0.0-a/VERSION	2010-06-23 11:03:20.000000000 +0000
   2.242 -+++ mpfr-3.0.0-b/VERSION	2010-06-25 13:23:13.000000000 +0000
   2.243 -@@ -1 +1 @@
   2.244 --3.0.0-p1
   2.245 -+3.0.0-p2
   2.246 -diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
   2.247 ---- mpfr-3.0.0-a/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   2.248 -+++ mpfr-3.0.0-b/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   2.249 -@@ -59,6 +59,9 @@
   2.250 - dnl sys/fpu.h - MIPS specific
   2.251 - AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
   2.252 - 
   2.253 -+dnl Check how to get `alloca'
   2.254 -+AC_FUNC_ALLOCA
   2.255 -+
   2.256 - dnl SIZE_MAX macro
   2.257 - gl_SIZE_MAX
   2.258 - 
   2.259 -diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
   2.260 ---- mpfr-3.0.0-a/configure	2010-06-10 11:00:51.000000000 +0000
   2.261 -+++ mpfr-3.0.0-b/configure	2010-06-25 13:23:05.000000000 +0000
   2.262 -@@ -783,6 +783,7 @@
   2.263 - OBJDUMP
   2.264 - DLLTOOL
   2.265 - AS
   2.266 -+ALLOCA
   2.267 - MPFR_LIBM
   2.268 - ANSI2KNR
   2.269 - U
   2.270 -@@ -5622,6 +5623,197 @@
   2.271 - done
   2.272 - 
   2.273 - 
   2.274 -+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
   2.275 -+# for constant arguments.  Useless!
   2.276 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
   2.277 -+$as_echo_n "checking for working alloca.h... " >&6; }
   2.278 -+if test "${ac_cv_working_alloca_h+set}" = set; then :
   2.279 -+  $as_echo_n "(cached) " >&6
   2.280 -+else
   2.281 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   2.282 -+/* end confdefs.h.  */
   2.283 -+#include <alloca.h>
   2.284 -+int
   2.285 -+main ()
   2.286 -+{
   2.287 -+char *p = (char *) alloca (2 * sizeof (int));
   2.288 -+			  if (p) return 0;
   2.289 -+  ;
   2.290 -+  return 0;
   2.291 -+}
   2.292 -+_ACEOF
   2.293 -+if ac_fn_c_try_link "$LINENO"; then :
   2.294 -+  ac_cv_working_alloca_h=yes
   2.295 -+else
   2.296 -+  ac_cv_working_alloca_h=no
   2.297 -+fi
   2.298 -+rm -f core conftest.err conftest.$ac_objext \
   2.299 -+    conftest$ac_exeext conftest.$ac_ext
   2.300 -+fi
   2.301 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
   2.302 -+$as_echo "$ac_cv_working_alloca_h" >&6; }
   2.303 -+if test $ac_cv_working_alloca_h = yes; then
   2.304 -+
   2.305 -+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
   2.306 -+
   2.307 -+fi
   2.308 -+
   2.309 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
   2.310 -+$as_echo_n "checking for alloca... " >&6; }
   2.311 -+if test "${ac_cv_func_alloca_works+set}" = set; then :
   2.312 -+  $as_echo_n "(cached) " >&6
   2.313 -+else
   2.314 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   2.315 -+/* end confdefs.h.  */
   2.316 -+#ifdef __GNUC__
   2.317 -+# define alloca __builtin_alloca
   2.318 -+#else
   2.319 -+# ifdef _MSC_VER
   2.320 -+#  include <malloc.h>
   2.321 -+#  define alloca _alloca
   2.322 -+# else
   2.323 -+#  ifdef HAVE_ALLOCA_H
   2.324 -+#   include <alloca.h>
   2.325 -+#  else
   2.326 -+#   ifdef _AIX
   2.327 -+ #pragma alloca
   2.328 -+#   else
   2.329 -+#    ifndef alloca /* predefined by HP cc +Olibcalls */
   2.330 -+char *alloca ();
   2.331 -+#    endif
   2.332 -+#   endif
   2.333 -+#  endif
   2.334 -+# endif
   2.335 -+#endif
   2.336 -+
   2.337 -+int
   2.338 -+main ()
   2.339 -+{
   2.340 -+char *p = (char *) alloca (1);
   2.341 -+				    if (p) return 0;
   2.342 -+  ;
   2.343 -+  return 0;
   2.344 -+}
   2.345 -+_ACEOF
   2.346 -+if ac_fn_c_try_link "$LINENO"; then :
   2.347 -+  ac_cv_func_alloca_works=yes
   2.348 -+else
   2.349 -+  ac_cv_func_alloca_works=no
   2.350 -+fi
   2.351 -+rm -f core conftest.err conftest.$ac_objext \
   2.352 -+    conftest$ac_exeext conftest.$ac_ext
   2.353 -+fi
   2.354 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
   2.355 -+$as_echo "$ac_cv_func_alloca_works" >&6; }
   2.356 -+
   2.357 -+if test $ac_cv_func_alloca_works = yes; then
   2.358 -+
   2.359 -+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
   2.360 -+
   2.361 -+else
   2.362 -+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
   2.363 -+# that cause trouble.  Some versions do not even contain alloca or
   2.364 -+# contain a buggy version.  If you still want to use their alloca,
   2.365 -+# use ar to extract alloca.o from them instead of compiling alloca.c.
   2.366 -+
   2.367 -+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
   2.368 -+
   2.369 -+$as_echo "#define C_ALLOCA 1" >>confdefs.h
   2.370 -+
   2.371 -+
   2.372 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
   2.373 -+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
   2.374 -+if test "${ac_cv_os_cray+set}" = set; then :
   2.375 -+  $as_echo_n "(cached) " >&6
   2.376 -+else
   2.377 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   2.378 -+/* end confdefs.h.  */
   2.379 -+#if defined CRAY && ! defined CRAY2
   2.380 -+webecray
   2.381 -+#else
   2.382 -+wenotbecray
   2.383 -+#endif
   2.384 -+
   2.385 -+_ACEOF
   2.386 -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   2.387 -+  $EGREP "webecray" >/dev/null 2>&1; then :
   2.388 -+  ac_cv_os_cray=yes
   2.389 -+else
   2.390 -+  ac_cv_os_cray=no
   2.391 -+fi
   2.392 -+rm -f conftest*
   2.393 -+
   2.394 -+fi
   2.395 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
   2.396 -+$as_echo "$ac_cv_os_cray" >&6; }
   2.397 -+if test $ac_cv_os_cray = yes; then
   2.398 -+  for ac_func in _getb67 GETB67 getb67; do
   2.399 -+    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   2.400 -+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   2.401 -+eval as_val=\$$as_ac_var
   2.402 -+   if test "x$as_val" = x""yes; then :
   2.403 -+
   2.404 -+cat >>confdefs.h <<_ACEOF
   2.405 -+#define CRAY_STACKSEG_END $ac_func
   2.406 -+_ACEOF
   2.407 -+
   2.408 -+    break
   2.409 -+fi
   2.410 -+
   2.411 -+  done
   2.412 -+fi
   2.413 -+
   2.414 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
   2.415 -+$as_echo_n "checking stack direction for C alloca... " >&6; }
   2.416 -+if test "${ac_cv_c_stack_direction+set}" = set; then :
   2.417 -+  $as_echo_n "(cached) " >&6
   2.418 -+else
   2.419 -+  if test "$cross_compiling" = yes; then :
   2.420 -+  ac_cv_c_stack_direction=0
   2.421 -+else
   2.422 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   2.423 -+/* end confdefs.h.  */
   2.424 -+$ac_includes_default
   2.425 -+int
   2.426 -+find_stack_direction ()
   2.427 -+{
   2.428 -+  static char *addr = 0;
   2.429 -+  auto char dummy;
   2.430 -+  if (addr == 0)
   2.431 -+    {
   2.432 -+      addr = &dummy;
   2.433 -+      return find_stack_direction ();
   2.434 -+    }
   2.435 -+  else
   2.436 -+    return (&dummy > addr) ? 1 : -1;
   2.437 -+}
   2.438 -+
   2.439 -+int
   2.440 -+main ()
   2.441 -+{
   2.442 -+  return find_stack_direction () < 0;
   2.443 -+}
   2.444 -+_ACEOF
   2.445 -+if ac_fn_c_try_run "$LINENO"; then :
   2.446 -+  ac_cv_c_stack_direction=1
   2.447 -+else
   2.448 -+  ac_cv_c_stack_direction=-1
   2.449 -+fi
   2.450 -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   2.451 -+  conftest.$ac_objext conftest.beam conftest.$ac_ext
   2.452 -+fi
   2.453 -+
   2.454 -+fi
   2.455 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
   2.456 -+$as_echo "$ac_cv_c_stack_direction" >&6; }
   2.457 -+cat >>confdefs.h <<_ACEOF
   2.458 -+#define STACK_DIRECTION $ac_cv_c_stack_direction
   2.459 -+_ACEOF
   2.460 -+
   2.461 -+
   2.462 -+fi
   2.463 -+
   2.464 -+
   2.465 - 
   2.466 -   for ac_header in stdint.h
   2.467 - do :
   2.468 -@@ -7564,13 +7756,13 @@
   2.469 - else
   2.470 -   lt_cv_nm_interface="BSD nm"
   2.471 -   echo "int some_variable = 0;" > conftest.$ac_ext
   2.472 --  (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
   2.473 -+  (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
   2.474 -   (eval "$ac_compile" 2>conftest.err)
   2.475 -   cat conftest.err >&5
   2.476 --  (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   2.477 -+  (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   2.478 -   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   2.479 -   cat conftest.err >&5
   2.480 --  (eval echo "\"\$as_me:7573: output\"" >&5)
   2.481 -+  (eval echo "\"\$as_me:7765: output\"" >&5)
   2.482 -   cat conftest.out >&5
   2.483 -   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
   2.484 -     lt_cv_nm_interface="MS dumpbin"
   2.485 -@@ -8772,7 +8964,7 @@
   2.486 -   ;;
   2.487 - *-*-irix6*)
   2.488 -   # Find out which ABI we are using.
   2.489 --  echo '#line 8775 "configure"' > conftest.$ac_ext
   2.490 -+  echo '#line 8967 "configure"' > conftest.$ac_ext
   2.491 -   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   2.492 -   (eval $ac_compile) 2>&5
   2.493 -   ac_status=$?
   2.494 -@@ -10032,11 +10224,11 @@
   2.495 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   2.496 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   2.497 -    -e 's:$: $lt_compiler_flag:'`
   2.498 --   (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
   2.499 -+   (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
   2.500 -    (eval "$lt_compile" 2>conftest.err)
   2.501 -    ac_status=$?
   2.502 -    cat conftest.err >&5
   2.503 --   echo "$as_me:10039: \$? = $ac_status" >&5
   2.504 -+   echo "$as_me:10231: \$? = $ac_status" >&5
   2.505 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   2.506 -      # The compiler can only warn and ignore the option if not recognized
   2.507 -      # So say no if there are warnings other than the usual output.
   2.508 -@@ -10371,11 +10563,11 @@
   2.509 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   2.510 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   2.511 -    -e 's:$: $lt_compiler_flag:'`
   2.512 --   (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
   2.513 -+   (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
   2.514 -    (eval "$lt_compile" 2>conftest.err)
   2.515 -    ac_status=$?
   2.516 -    cat conftest.err >&5
   2.517 --   echo "$as_me:10378: \$? = $ac_status" >&5
   2.518 -+   echo "$as_me:10570: \$? = $ac_status" >&5
   2.519 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   2.520 -      # The compiler can only warn and ignore the option if not recognized
   2.521 -      # So say no if there are warnings other than the usual output.
   2.522 -@@ -10476,11 +10668,11 @@
   2.523 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   2.524 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   2.525 -    -e 's:$: $lt_compiler_flag:'`
   2.526 --   (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
   2.527 -+   (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
   2.528 -    (eval "$lt_compile" 2>out/conftest.err)
   2.529 -    ac_status=$?
   2.530 -    cat out/conftest.err >&5
   2.531 --   echo "$as_me:10483: \$? = $ac_status" >&5
   2.532 -+   echo "$as_me:10675: \$? = $ac_status" >&5
   2.533 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   2.534 -    then
   2.535 -      # The compiler can only warn and ignore the option if not recognized
   2.536 -@@ -10531,11 +10723,11 @@
   2.537 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   2.538 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   2.539 -    -e 's:$: $lt_compiler_flag:'`
   2.540 --   (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
   2.541 -+   (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
   2.542 -    (eval "$lt_compile" 2>out/conftest.err)
   2.543 -    ac_status=$?
   2.544 -    cat out/conftest.err >&5
   2.545 --   echo "$as_me:10538: \$? = $ac_status" >&5
   2.546 -+   echo "$as_me:10730: \$? = $ac_status" >&5
   2.547 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   2.548 -    then
   2.549 -      # The compiler can only warn and ignore the option if not recognized
   2.550 -@@ -12915,7 +13107,7 @@
   2.551 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   2.552 -   lt_status=$lt_dlunknown
   2.553 -   cat > conftest.$ac_ext <<_LT_EOF
   2.554 --#line 12918 "configure"
   2.555 -+#line 13110 "configure"
   2.556 - #include "confdefs.h"
   2.557 - 
   2.558 - #if HAVE_DLFCN_H
   2.559 -@@ -13011,7 +13203,7 @@
   2.560 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   2.561 -   lt_status=$lt_dlunknown
   2.562 -   cat > conftest.$ac_ext <<_LT_EOF
   2.563 --#line 13014 "configure"
   2.564 -+#line 13206 "configure"
   2.565 - #include "confdefs.h"
   2.566 - 
   2.567 - #if HAVE_DLFCN_H
   2.568 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   2.569 ---- mpfr-3.0.0-a/mpfr.h	2010-06-23 11:03:20.000000000 +0000
   2.570 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   2.571 -@@ -27,7 +27,7 @@
   2.572 - #define MPFR_VERSION_MAJOR 3
   2.573 - #define MPFR_VERSION_MINOR 0
   2.574 - #define MPFR_VERSION_PATCHLEVEL 0
   2.575 --#define MPFR_VERSION_STRING "3.0.0-p1"
   2.576 -+#define MPFR_VERSION_STRING "3.0.0-p2"
   2.577 - 
   2.578 - /* Macros dealing with MPFR VERSION */
   2.579 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.580 -diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
   2.581 ---- mpfr-3.0.0-a/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   2.582 -+++ mpfr-3.0.0-b/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   2.583 -@@ -960,6 +960,7 @@
   2.584 - red=; grn=; lgn=; blu=; std=
   2.585 - DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   2.586 - ACLOCAL = @ACLOCAL@
   2.587 -+ALLOCA = @ALLOCA@
   2.588 - AMTAR = @AMTAR@
   2.589 - AR = @AR@
   2.590 - AS = @AS@
   2.591 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   2.592 ---- mpfr-3.0.0-a/version.c	2010-06-23 11:03:20.000000000 +0000
   2.593 -+++ mpfr-3.0.0-b/version.c	2010-06-25 13:23:13.000000000 +0000
   2.594 -@@ -25,5 +25,5 @@
   2.595 - const char *
   2.596 - mpfr_get_version (void)
   2.597 - {
   2.598 --  return "3.0.0-p1";
   2.599 -+  return "3.0.0-p2";
   2.600 - }
   2.601 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   2.602 ---- mpfr-3.0.0-a/PATCHES	2010-07-10 00:11:19.000000000 +0000
   2.603 -+++ mpfr-3.0.0-b/PATCHES	2010-07-10 00:12:50.000000000 +0000
   2.604 -@@ -0,0 +1 @@
   2.605 -+gamma_underflow
   2.606 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   2.607 ---- mpfr-3.0.0-a/VERSION	2010-06-25 13:23:13.000000000 +0000
   2.608 -+++ mpfr-3.0.0-b/VERSION	2010-07-10 00:11:53.000000000 +0000
   2.609 -@@ -1 +1 @@
   2.610 --3.0.0-p2
   2.611 -+3.0.0-p3
   2.612 -diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
   2.613 ---- mpfr-3.0.0-a/gamma.c	2010-06-10 11:00:14.000000000 +0000
   2.614 -+++ mpfr-3.0.0-b/gamma.c	2010-07-10 00:11:46.000000000 +0000
   2.615 -@@ -274,7 +274,7 @@
   2.616 -       /* we want an upper bound for x * [log(2-x)-1].
   2.617 -          since x < 0, we need a lower bound on log(2-x) */
   2.618 -       mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
   2.619 --      mpfr_log (xp, xp, MPFR_RNDD);
   2.620 -+      mpfr_log2 (xp, xp, MPFR_RNDD);
   2.621 -       mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
   2.622 -       mpfr_mul (xp, xp, x, MPFR_RNDU);
   2.623 - 
   2.624 -@@ -303,8 +303,8 @@
   2.625 -         {
   2.626 -           mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
   2.627 -           mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
   2.628 --          mpfr_log (tmp, tmp, MPFR_RNDU);
   2.629 --          mpfr_add (tmp, tmp, xp, MPFR_RNDU);
   2.630 -+          mpfr_log2 (tmp, tmp, MPFR_RNDU);
   2.631 -+          mpfr_add (xp, tmp, xp, MPFR_RNDU);
   2.632 -           underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
   2.633 -         }
   2.634 - 
   2.635 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   2.636 ---- mpfr-3.0.0-a/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   2.637 -+++ mpfr-3.0.0-b/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   2.638 -@@ -27,7 +27,7 @@
   2.639 - #define MPFR_VERSION_MAJOR 3
   2.640 - #define MPFR_VERSION_MINOR 0
   2.641 - #define MPFR_VERSION_PATCHLEVEL 0
   2.642 --#define MPFR_VERSION_STRING "3.0.0-p2"
   2.643 -+#define MPFR_VERSION_STRING "3.0.0-p3"
   2.644 - 
   2.645 - /* Macros dealing with MPFR VERSION */
   2.646 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.647 -diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
   2.648 ---- mpfr-3.0.0-a/tests/tgamma.c	2010-06-10 11:00:13.000000000 +0000
   2.649 -+++ mpfr-3.0.0-b/tests/tgamma.c	2010-07-10 00:11:46.000000000 +0000
   2.650 -@@ -461,6 +461,20 @@
   2.651 -   mpfr_clear (x);
   2.652 - }
   2.653 - 
   2.654 -+/* bug found by Stathis, only occurs on 32-bit machines */
   2.655 -+static void
   2.656 -+test20100709 (void)
   2.657 -+{
   2.658 -+  mpfr_t x;
   2.659 -+  int inex;
   2.660 -+
   2.661 -+  mpfr_init2 (x, 100);
   2.662 -+  mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
   2.663 -+  inex = mpfr_gamma (x, x, MPFR_RNDN);
   2.664 -+  MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
   2.665 -+  mpfr_clear (x);
   2.666 -+}
   2.667 -+
   2.668 - int
   2.669 - main (int argc, char *argv[])
   2.670 - {
   2.671 -@@ -471,6 +485,7 @@
   2.672 -   test_generic (2, 100, 2);
   2.673 -   gamma_integer ();
   2.674 -   test20071231 ();
   2.675 -+  test20100709 ();
   2.676 - 
   2.677 -   data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
   2.678 - 
   2.679 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   2.680 ---- mpfr-3.0.0-a/version.c	2010-06-25 13:23:13.000000000 +0000
   2.681 -+++ mpfr-3.0.0-b/version.c	2010-07-10 00:11:53.000000000 +0000
   2.682 -@@ -25,5 +25,5 @@
   2.683 - const char *
   2.684 - mpfr_get_version (void)
   2.685 - {
   2.686 --  return "3.0.0-p2";
   2.687 -+  return "3.0.0-p3";
   2.688 - }
   2.689 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   2.690 ---- mpfr-3.0.0-a/PATCHES	2010-09-07 08:44:01.000000000 +0000
   2.691 -+++ mpfr-3.0.0-b/PATCHES	2010-09-07 08:48:46.000000000 +0000
   2.692 -@@ -0,0 +1 @@
   2.693 -+mpfr_cmp/set_ui/si
   2.694 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   2.695 ---- mpfr-3.0.0-a/VERSION	2010-07-10 00:11:53.000000000 +0000
   2.696 -+++ mpfr-3.0.0-b/VERSION	2010-09-07 08:46:06.000000000 +0000
   2.697 -@@ -1 +1 @@
   2.698 --3.0.0-p3
   2.699 -+3.0.0-p4
   2.700 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   2.701 ---- mpfr-3.0.0-a/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   2.702 -+++ mpfr-3.0.0-b/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   2.703 -@@ -27,7 +27,7 @@
   2.704 - #define MPFR_VERSION_MAJOR 3
   2.705 - #define MPFR_VERSION_MINOR 0
   2.706 - #define MPFR_VERSION_PATCHLEVEL 0
   2.707 --#define MPFR_VERSION_STRING "3.0.0-p3"
   2.708 -+#define MPFR_VERSION_STRING "3.0.0-p4"
   2.709 - 
   2.710 - /* Macros dealing with MPFR VERSION */
   2.711 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.712 -@@ -798,35 +798,45 @@
   2.713 -      anyway. Checking with other ICC versions is needed. Possibly detect
   2.714 -      whether warnings are produced or not with a configure test.
   2.715 -    + Remove C++ too, since it complains too much. */
   2.716 -+/* Added casts to improve robustness in case of undefined behavior and
   2.717 -+   compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
   2.718 -+   use such extensions, but these macros will be used by 3rd-party code,
   2.719 -+   where such extensions may be required.
   2.720 -+   Moreover casts to unsigned long have been added to avoid warnings in
   2.721 -+   programs that use MPFR and are compiled with -Wconversion; such casts
   2.722 -+   are OK since if X is a constant expression, then (unsigned long) X is
   2.723 -+   also a constant expression, so that the optimizations still work. */
   2.724 - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
   2.725 - #if (__GNUC__ >= 2)
   2.726 - #undef mpfr_cmp_ui
   2.727 --/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
   2.728 --#define mpfr_cmp_ui(_f,_u)                 \
   2.729 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   2.730 --   mpfr_sgn (_f) :                         \
   2.731 --   mpfr_cmp_ui_2exp ((_f),(_u),0))
   2.732 -+/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
   2.733 -+   But warning! mpfr_sgn is specified as a macro in the API, thus the macro
   2.734 -+   mustn't be used if side effects are possible, like here. */
   2.735 -+#define mpfr_cmp_ui(_f,_u)                                      \
   2.736 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   2.737 -+   (mpfr_sgn) (_f) :                                            \
   2.738 -+   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
   2.739 - #undef mpfr_cmp_si
   2.740 --#define mpfr_cmp_si(_f,_s)                 \
   2.741 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   2.742 --   mpfr_cmp_ui ((_f), (_s)) :              \
   2.743 --   mpfr_cmp_si_2exp ((_f), (_s), 0))
   2.744 -+#define mpfr_cmp_si(_f,_s)                              \
   2.745 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
   2.746 -+   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
   2.747 -+   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
   2.748 - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
   2.749 - #undef mpfr_set_ui
   2.750 --#define mpfr_set_ui(_f,_u,_r)              \
   2.751 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   2.752 --   __extension__ ({                        \
   2.753 --     mpfr_ptr _p = (_f);                   \
   2.754 --     _p->_mpfr_sign = 1;                   \
   2.755 --     _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
   2.756 --     (void) (_r); 0; }) :                  \
   2.757 --   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
   2.758 -+#define mpfr_set_ui(_f,_u,_r)                                   \
   2.759 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   2.760 -+   __extension__ ({                                             \
   2.761 -+       mpfr_ptr _p = (_f);                                      \
   2.762 -+       _p->_mpfr_sign = 1;                                      \
   2.763 -+       _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
   2.764 -+       (void) (_r); 0; }) :                                     \
   2.765 -+   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
   2.766 - #endif
   2.767 - #undef mpfr_set_si
   2.768 --#define mpfr_set_si(_f,_s,_r)              \
   2.769 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   2.770 --   mpfr_set_ui ((_f), (_s), (_r)) :        \
   2.771 --   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
   2.772 -+#define mpfr_set_si(_f,_s,_r)                                   \
   2.773 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
   2.774 -+   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
   2.775 -+   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
   2.776 - #endif
   2.777 - #endif
   2.778 - 
   2.779 -diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
   2.780 ---- mpfr-3.0.0-a/tests/tcmp_ui.c	2010-06-10 11:00:13.000000000 +0000
   2.781 -+++ mpfr-3.0.0-b/tests/tcmp_ui.c	2010-09-07 08:45:12.000000000 +0000
   2.782 -@@ -88,6 +88,126 @@
   2.783 -   mpfr_clear (x);
   2.784 - }
   2.785 - 
   2.786 -+/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
   2.787 -+   with __builtin_constant_p for GCC, check that side effects are
   2.788 -+   handled correctly. */
   2.789 -+static void
   2.790 -+check_macros (void)
   2.791 -+{
   2.792 -+  mpfr_t x;
   2.793 -+  int c;
   2.794 -+
   2.795 -+  mpfr_init2 (x, 32);
   2.796 -+
   2.797 -+  c = 0;
   2.798 -+  mpfr_set_ui (x, 17, MPFR_RNDN);
   2.799 -+  if (mpfr_cmp_ui (x, 17) != 0)
   2.800 -+    {
   2.801 -+      printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
   2.802 -+      exit (1);
   2.803 -+    }
   2.804 -+  if (mpfr_cmp_ui (x, (c++, 17)) != 0)
   2.805 -+    {
   2.806 -+      printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
   2.807 -+      exit (1);
   2.808 -+    }
   2.809 -+  if (c != 1)
   2.810 -+    {
   2.811 -+      printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
   2.812 -+              "(c = %d instead of 1)\n", c);
   2.813 -+      exit (1);
   2.814 -+    }
   2.815 -+  if (mpfr_cmp_si (x, 17) != 0)
   2.816 -+    {
   2.817 -+      printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
   2.818 -+      exit (1);
   2.819 -+    }
   2.820 -+  if (mpfr_cmp_si (x, (c++, 17)) != 0)
   2.821 -+    {
   2.822 -+      printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
   2.823 -+      exit (1);
   2.824 -+    }
   2.825 -+  if (c != 2)
   2.826 -+    {
   2.827 -+      printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
   2.828 -+              "(c = %d instead of 2)\n", c);
   2.829 -+      exit (1);
   2.830 -+    }
   2.831 -+
   2.832 -+  c = 0;
   2.833 -+  mpfr_set_ui (x, 0, MPFR_RNDN);
   2.834 -+  if (mpfr_cmp_ui (x, 0) != 0)
   2.835 -+    {
   2.836 -+      printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
   2.837 -+      exit (1);
   2.838 -+    }
   2.839 -+  if (mpfr_cmp_ui (x, (c++, 0)) != 0)
   2.840 -+    {
   2.841 -+      printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
   2.842 -+      exit (1);
   2.843 -+    }
   2.844 -+  if (c != 1)
   2.845 -+    {
   2.846 -+      printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
   2.847 -+              "(c = %d instead of 1)\n", c);
   2.848 -+      exit (1);
   2.849 -+    }
   2.850 -+  if (mpfr_cmp_si (x, 0) != 0)
   2.851 -+    {
   2.852 -+      printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
   2.853 -+      exit (1);
   2.854 -+    }
   2.855 -+  if (mpfr_cmp_si (x, (c++, 0)) != 0)
   2.856 -+    {
   2.857 -+      printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
   2.858 -+      exit (1);
   2.859 -+    }
   2.860 -+  if (c != 2)
   2.861 -+    {
   2.862 -+      printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
   2.863 -+              "(c = %d instead of 2)\n", c);
   2.864 -+      exit (1);
   2.865 -+    }
   2.866 -+
   2.867 -+  mpfr_clear (x);
   2.868 -+}
   2.869 -+
   2.870 -+/* Bug in r7114 */
   2.871 -+static void
   2.872 -+test_macros (void)
   2.873 -+{
   2.874 -+  mpfr_t x[3];
   2.875 -+  mpfr_ptr p;
   2.876 -+
   2.877 -+  mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
   2.878 -+  mpfr_set_ui (x[0], 0, MPFR_RNDN);
   2.879 -+  p = x[0];
   2.880 -+  if (mpfr_cmp_ui (p++, 0) != 0)
   2.881 -+    {
   2.882 -+      printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
   2.883 -+      exit (1);
   2.884 -+    }
   2.885 -+  if (p != x[1])
   2.886 -+    {
   2.887 -+      printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
   2.888 -+              (int) (p - x[0]));
   2.889 -+      exit (1);
   2.890 -+    }
   2.891 -+  p = x[0];
   2.892 -+  if (mpfr_cmp_si (p++, 0) != 0)
   2.893 -+    {
   2.894 -+      printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
   2.895 -+      exit (1);
   2.896 -+    }
   2.897 -+  if (p != x[1])
   2.898 -+    {
   2.899 -+      printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
   2.900 -+              (int) (p - x[0]));
   2.901 -+      exit (1);
   2.902 -+    }
   2.903 -+  mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
   2.904 -+}
   2.905 -+
   2.906 - int
   2.907 - main (void)
   2.908 - {
   2.909 -@@ -216,6 +336,8 @@
   2.910 -   mpfr_clear (x);
   2.911 - 
   2.912 -   check_nan ();
   2.913 -+  check_macros ();
   2.914 -+  test_macros ();
   2.915 - 
   2.916 -   tests_end_mpfr ();
   2.917 -   return 0;
   2.918 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   2.919 ---- mpfr-3.0.0-a/version.c	2010-07-10 00:11:53.000000000 +0000
   2.920 -+++ mpfr-3.0.0-b/version.c	2010-09-07 08:46:06.000000000 +0000
   2.921 -@@ -25,5 +25,5 @@
   2.922 - const char *
   2.923 - mpfr_get_version (void)
   2.924 - {
   2.925 --  return "3.0.0-p3";
   2.926 -+  return "3.0.0-p4";
   2.927 - }
   2.928 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   2.929 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 20:28:38.000000000 +0000
   2.930 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:28:38.000000000 +0000
   2.931 -@@ -0,0 +1 @@
   2.932 -+tcan_round
   2.933 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   2.934 ---- mpfr-3.0.0-a/VERSION	2010-09-07 08:46:06.000000000 +0000
   2.935 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 20:28:38.000000000 +0000
   2.936 -@@ -1 +1 @@
   2.937 --3.0.0-p4
   2.938 -+3.0.0-p5
   2.939 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   2.940 ---- mpfr-3.0.0-a/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   2.941 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   2.942 -@@ -27,7 +27,7 @@
   2.943 - #define MPFR_VERSION_MAJOR 3
   2.944 - #define MPFR_VERSION_MINOR 0
   2.945 - #define MPFR_VERSION_PATCHLEVEL 0
   2.946 --#define MPFR_VERSION_STRING "3.0.0-p4"
   2.947 -+#define MPFR_VERSION_STRING "3.0.0-p5"
   2.948 - 
   2.949 - /* Macros dealing with MPFR VERSION */
   2.950 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.951 -diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
   2.952 ---- mpfr-3.0.0-a/tests/tcan_round.c	2010-06-10 11:00:13.000000000 +0000
   2.953 -+++ mpfr-3.0.0-b/tests/tcan_round.c	2010-10-21 20:28:38.000000000 +0000
   2.954 -@@ -41,7 +41,7 @@
   2.955 -       /* avoid mpn_random which leaks memory */
   2.956 -       for (i = 0; i < n; i++)
   2.957 -         buf[i] = randlimb ();
   2.958 --      p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   2.959 -+      p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   2.960 -       err = p + randlimb () % GMP_NUMB_BITS;
   2.961 -       r1 = mpfr_round_p (buf, n, err, p);
   2.962 -       r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
   2.963 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   2.964 ---- mpfr-3.0.0-a/version.c	2010-09-07 08:46:06.000000000 +0000
   2.965 -+++ mpfr-3.0.0-b/version.c	2010-10-21 20:28:38.000000000 +0000
   2.966 -@@ -25,5 +25,5 @@
   2.967 - const char *
   2.968 - mpfr_get_version (void)
   2.969 - {
   2.970 --  return "3.0.0-p4";
   2.971 -+  return "3.0.0-p5";
   2.972 - }
   2.973 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   2.974 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 20:59:32.000000000 +0000
   2.975 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:59:32.000000000 +0000
   2.976 -@@ -0,0 +1 @@
   2.977 -+mpfr_sub1
   2.978 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   2.979 ---- mpfr-3.0.0-a/VERSION	2010-10-21 20:28:38.000000000 +0000
   2.980 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 20:59:32.000000000 +0000
   2.981 -@@ -1 +1 @@
   2.982 --3.0.0-p5
   2.983 -+3.0.0-p6
   2.984 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   2.985 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   2.986 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:59:32.000000000 +0000
   2.987 -@@ -27,7 +27,7 @@
   2.988 - #define MPFR_VERSION_MAJOR 3
   2.989 - #define MPFR_VERSION_MINOR 0
   2.990 - #define MPFR_VERSION_PATCHLEVEL 0
   2.991 --#define MPFR_VERSION_STRING "3.0.0-p5"
   2.992 -+#define MPFR_VERSION_STRING "3.0.0-p6"
   2.993 - 
   2.994 - /* Macros dealing with MPFR VERSION */
   2.995 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.996 -diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
   2.997 ---- mpfr-3.0.0-a/sub1.c	2010-06-10 11:00:14.000000000 +0000
   2.998 -+++ mpfr-3.0.0-b/sub1.c	2010-10-21 20:59:32.000000000 +0000
   2.999 -@@ -37,7 +37,9 @@
  2.1000 -   mp_size_t cancel2, an, bn, cn, cn0;
  2.1001 -   mp_limb_t *ap, *bp, *cp;
  2.1002 -   mp_limb_t carry, bb, cc, borrow = 0;
  2.1003 --  int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
  2.1004 -+  int inexact, shift_b, shift_c, add_exp = 0;
  2.1005 -+  int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
  2.1006 -+                      negative if low(b) < low(c), positive if low(b)>low(c) */
  2.1007 -   int sh, k;
  2.1008 -   MPFR_TMP_DECL(marker);
  2.1009 - 
  2.1010 -@@ -196,7 +198,8 @@
  2.1011 -     }
  2.1012 - 
  2.1013 - #ifdef DEBUG
  2.1014 --  printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
  2.1015 -+  printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
  2.1016 -+          mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
  2.1017 -           (unsigned long) diff_exp);
  2.1018 - #endif
  2.1019 - 
  2.1020 -@@ -307,17 +310,18 @@
  2.1021 -     {
  2.1022 -       if (MPFR_LIKELY(sh))
  2.1023 -         {
  2.1024 --          is_exact = (carry == 0);
  2.1025 -           /* can decide except when carry = 2^(sh-1) [middle]
  2.1026 -              or carry = 0 [truncate, but cannot decide inexact flag] */
  2.1027 --          down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
  2.1028 -           if (carry > (MPFR_LIMB_ONE << (sh - 1)))
  2.1029 -             goto add_one_ulp;
  2.1030 --          else if ((0 < carry) && down)
  2.1031 -+          else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
  2.1032 -             {
  2.1033 -               inexact = -1; /* result if smaller than exact value */
  2.1034 -               goto truncate;
  2.1035 -             }
  2.1036 -+          /* now carry = 2^(sh-1), in which case cmp_low=2,
  2.1037 -+             or carry = 0, in which case cmp_low=0 */
  2.1038 -+          cmp_low = (carry == 0) ? 0 : 2;
  2.1039 -         }
  2.1040 -     }
  2.1041 -   else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
  2.1042 -@@ -344,12 +348,32 @@
  2.1043 -   cn -= (long int) an + cancel2;
  2.1044 - 
  2.1045 - #ifdef DEBUG
  2.1046 --  printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
  2.1047 -+  printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
  2.1048 -           sh, (unsigned long) carry, (long) bn, (long) cn);
  2.1049 - #endif
  2.1050 - 
  2.1051 -+  /* for rounding to nearest, we couldn't conclude up to here in the following
  2.1052 -+     cases:
  2.1053 -+     1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
  2.1054 -+        or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
  2.1055 -+     2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
  2.1056 -+        -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
  2.1057 -+        we can't decide the rounding, in that case cmp_low=2:
  2.1058 -+        either we truncate and flag=-1, or we add one ulp and flag=1
  2.1059 -+     3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
  2.1060 -+        truncate but we can't decide the ternary value, here cmp_low=0:
  2.1061 -+        -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
  2.1062 -+        we always truncate and inexact can be any of -1,0,1
  2.1063 -+  */
  2.1064 -+
  2.1065 -+  /* note: here cn might exceed cn0, in which case we consider a zero limb */
  2.1066 -   for (k = 0; (bn > 0) || (cn > 0); k = 1)
  2.1067 -     {
  2.1068 -+      /* if cmp_low < 0, we know low(b) - low(c) < 0
  2.1069 -+         if cmp_low > 0, we know low(b) - low(c) > 0
  2.1070 -+            (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
  2.1071 -+         if cmp_low = 0, so far low(b) - low(c) = 0 */
  2.1072 -+
  2.1073 -       /* get next limbs */
  2.1074 -       bb = (bn > 0) ? bp[--bn] : 0;
  2.1075 -       if ((cn > 0) && (cn-- <= cn0))
  2.1076 -@@ -357,76 +381,115 @@
  2.1077 -       else
  2.1078 -         cc = 0;
  2.1079 - 
  2.1080 --      /* down is set when low(b) < low(c) */
  2.1081 --      if (down == 0)
  2.1082 --        down = (bb < cc);
  2.1083 -+      /* cmp_low compares low(b) and low(c) */
  2.1084 -+      if (cmp_low == 0) /* case 1 or 3 */
  2.1085 -+        cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
  2.1086 -+
  2.1087 -+      /* Case 1 for k=0 splits into 7 subcases:
  2.1088 -+         1a: bb > cc + half
  2.1089 -+         1b: bb = cc + half
  2.1090 -+         1c: 0 < bb - cc < half
  2.1091 -+         1d: bb = cc
  2.1092 -+         1e: -half < bb - cc < 0
  2.1093 -+         1f: bb - cc = -half
  2.1094 -+         1g: bb - cc < -half
  2.1095 -+
  2.1096 -+         Case 2 splits into 3 subcases:
  2.1097 -+         2a: bb > cc
  2.1098 -+         2b: bb = cc
  2.1099 -+         2c: bb < cc
  2.1100 -+
  2.1101 -+         Case 3 splits into 3 subcases:
  2.1102 -+         3a: bb > cc
  2.1103 -+         3b: bb = cc
  2.1104 -+         3c: bb < cc
  2.1105 -+      */
  2.1106 - 
  2.1107 -       /* the case rounding to nearest with sh=0 is special since one couldn't
  2.1108 -          subtract above 1/2 ulp in the trailing limb of the result */
  2.1109 --      if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
  2.1110 -+      if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
  2.1111 -         {
  2.1112 -           mp_limb_t half = MPFR_LIMB_HIGHBIT;
  2.1113 - 
  2.1114 --          is_exact = (bb == cc);
  2.1115 --
  2.1116 -           /* add one ulp if bb > cc + half
  2.1117 -              truncate if cc - half < bb < cc + half
  2.1118 -              sub one ulp if bb < cc - half
  2.1119 -           */
  2.1120 - 
  2.1121 --          if (down)
  2.1122 -+          if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
  2.1123 -+                              cases 1e, 1f and 1g */
  2.1124 -             {
  2.1125 -               if (cc >= half)
  2.1126 -                 cc -= half;
  2.1127 --              else
  2.1128 -+              else /* since bb < cc < half, bb+half < 2*half */
  2.1129 -                 bb += half;
  2.1130 -+              /* now we have bb < cc + half:
  2.1131 -+                 we have to subtract one ulp if bb < cc,
  2.1132 -+                 and truncate if bb > cc */
  2.1133 -             }
  2.1134 --          else /* bb >= cc */
  2.1135 -+          else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
  2.1136 -             {
  2.1137 -               if (cc < half)
  2.1138 -                 cc += half;
  2.1139 --              else
  2.1140 -+              else /* since bb >= cc >= half, bb - half >= 0 */
  2.1141 -                 bb -= half;
  2.1142 -+              /* now we have bb > cc - half: we have to add one ulp if bb > cc,
  2.1143 -+                 and truncate if bb < cc */
  2.1144 -+              if (cmp_low > 0)
  2.1145 -+                cmp_low = 2;
  2.1146 -             }
  2.1147 -         }
  2.1148 - 
  2.1149 - #ifdef DEBUG
  2.1150 --      printf ("    bb=%lu cc=%lu down=%d is_exact=%d\n",
  2.1151 --              (unsigned long) bb, (unsigned long) cc, down, is_exact);
  2.1152 -+      printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
  2.1153 -+              (unsigned long) bb, (unsigned long) cc, cmp_low);
  2.1154 - #endif
  2.1155 --      if (bb < cc)
  2.1156 -+      if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
  2.1157 -+                          one ulp */
  2.1158 -         {
  2.1159 -           if (rnd_mode == MPFR_RNDZ)
  2.1160 --            goto sub_one_ulp;
  2.1161 -+            goto sub_one_ulp; /* set inexact=-1 */
  2.1162 -           else if (rnd_mode != MPFR_RNDN) /* round away */
  2.1163 -             {
  2.1164 -               inexact = 1;
  2.1165 -               goto truncate;
  2.1166 -             }
  2.1167 --          else /* round to nearest: special case here since for sh=k=0
  2.1168 --                  bb = bb0 - MPFR_LIMB_HIGHBIT */
  2.1169 -+          else /* round to nearest */
  2.1170 -             {
  2.1171 --              if (is_exact && sh == 0)
  2.1172 --                {
  2.1173 --                  /* For k=0 we can't decide exactness since it may depend
  2.1174 --                     from low order bits.
  2.1175 --                     For k=1, the first low limbs matched: low(b)-low(c)<0. */
  2.1176 --                  if (k)
  2.1177 --                    {
  2.1178 --                      inexact = 1;
  2.1179 --                      goto truncate;
  2.1180 --                    }
  2.1181 --                }
  2.1182 --              else if (down && sh == 0)
  2.1183 --                goto sub_one_ulp;
  2.1184 --              else
  2.1185 --                {
  2.1186 --                  inexact = (is_exact) ? 1 : -1;
  2.1187 -+              /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
  2.1188 -+                 whatever the value of sh.
  2.1189 -+                 If sh>0, then cmp_low < 0 implies that the initial neglected
  2.1190 -+                 sh bits were 0 (otherwise cmp_low=2 initially), thus the
  2.1191 -+                 weight of the new bits is less than 0.5 ulp too.
  2.1192 -+                 If k > 0 (and sh=0) this means that either the first neglected
  2.1193 -+                 limbs bb and cc were equal (thus cmp_low was 0 for k=0),
  2.1194 -+                 or we had bb - cc = -0.5 ulp or 0.5 ulp.
  2.1195 -+                 The last case is not possible here since we would have
  2.1196 -+                 cmp_low > 0 which is sticky.
  2.1197 -+                 In the first case (where we have cmp_low = -1), we truncate,
  2.1198 -+                 whereas in the 2nd case we have cmp_low = -2 and we subtract
  2.1199 -+                 one ulp.
  2.1200 -+              */
  2.1201 -+              if (bb > cc || sh > 0 || cmp_low == -1)
  2.1202 -+                {  /* -0.5 ulp < low(b)-low(c) < 0,
  2.1203 -+                      bb > cc corresponds to cases 1e and 1f1
  2.1204 -+                      sh > 0 corresponds to cases 3c and 3b3
  2.1205 -+                      cmp_low = -1 corresponds to case 1d3 (also 3b3) */
  2.1206 -+                  inexact = 1;
  2.1207 -                   goto truncate;
  2.1208 -                 }
  2.1209 -+              else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
  2.1210 -+                                   this corresponds to cases 1g and 1f3 */
  2.1211 -+                goto sub_one_ulp;
  2.1212 -+              /* the only case where we can't conclude is sh=0 and bb=cc,
  2.1213 -+                 i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
  2.1214 -+                 we don't know if we must truncate or subtract one ulp.
  2.1215 -+                 Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
  2.1216 -+                 now, since low(b) - low(c) > 1/2^sh */
  2.1217 -             }
  2.1218 -         }
  2.1219 --      else if (bb > cc)
  2.1220 -+      else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
  2.1221 -+                               add one ulp */
  2.1222 -         {
  2.1223 -           if (rnd_mode == MPFR_RNDZ)
  2.1224 -             {
  2.1225 -@@ -437,34 +500,70 @@
  2.1226 -             goto add_one_ulp;
  2.1227 -           else /* round to nearest */
  2.1228 -             {
  2.1229 --              if (is_exact)
  2.1230 -+              if (bb > cc)
  2.1231 -                 {
  2.1232 --                  inexact = -1;
  2.1233 --                  goto truncate;
  2.1234 -+                  /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
  2.1235 -+                     and similarly when cmp_low=2 */
  2.1236 -+                  if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
  2.1237 -+                    goto add_one_ulp;
  2.1238 -+                  /* sh > 0 and cmp_low > 0: this implies that the sh initial
  2.1239 -+                     neglected bits were 0, and the remaining low(b)-low(c)>0,
  2.1240 -+                     but its weight is less than 0.5 ulp */
  2.1241 -+                  else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
  2.1242 -+                          cases 3a, 1d1 and 3b1 */
  2.1243 -+                    {
  2.1244 -+                      inexact = -1;
  2.1245 -+                      goto truncate;
  2.1246 -+                    }
  2.1247 -                 }
  2.1248 --              else if (down)
  2.1249 -+              else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
  2.1250 -+                                   1b3, 2b3 and 2c */
  2.1251 -                 {
  2.1252 --                  inexact = 1;
  2.1253 -+                  inexact = -1;
  2.1254 -                   goto truncate;
  2.1255 -                 }
  2.1256 --              else
  2.1257 --                goto add_one_ulp;
  2.1258 -+              /* the only case where we can't conclude is bb=cc, i.e.,
  2.1259 -+                 low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
  2.1260 -+                 if we must truncate or add one ulp. */
  2.1261 -             }
  2.1262 -         }
  2.1263 -+      /* after k=0, we cannot conclude in the following cases, we split them
  2.1264 -+         according to the values of bb and cc for k=1:
  2.1265 -+         1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
  2.1266 -+             1b1. bb > cc: add one ulp, inex = 1
  2.1267 -+             1b2: bb = cc: cannot conclude
  2.1268 -+             1b3: bb < cc: truncate, inex = -1
  2.1269 -+         1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
  2.1270 -+             1d1: bb > cc: truncate, inex = -1
  2.1271 -+             1d2: bb = cc: cannot conclude
  2.1272 -+             1d3: bb < cc: truncate, inex = +1
  2.1273 -+         1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
  2.1274 -+             1f1: bb > cc: truncate, inex = +1
  2.1275 -+             1f2: bb = cc: cannot conclude
  2.1276 -+             1f3: bb < cc: sub one ulp, inex = -1
  2.1277 -+         2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
  2.1278 -+             2b1. bb > cc: add one ulp, inex = 1
  2.1279 -+             2b2: bb = cc: cannot conclude
  2.1280 -+             2b3: bb < cc: truncate, inex = -1
  2.1281 -+         3b. sh > 0 and cmp_low = 0 [around 0]
  2.1282 -+             3b1. bb > cc: truncate, inex = -1
  2.1283 -+             3b2: bb = cc: cannot conclude
  2.1284 -+             3b3: bb < cc: truncate, inex = +1
  2.1285 -+      */
  2.1286 -     }
  2.1287 - 
  2.1288 --  if ((rnd_mode == MPFR_RNDN) && !is_exact)
  2.1289 -+  if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
  2.1290 -     {
  2.1291 -       /* even rounding rule */
  2.1292 -       if ((ap[0] >> sh) & 1)
  2.1293 -         {
  2.1294 --          if (down)
  2.1295 -+          if (cmp_low < 0)
  2.1296 -             goto sub_one_ulp;
  2.1297 -           else
  2.1298 -             goto add_one_ulp;
  2.1299 -         }
  2.1300 -       else
  2.1301 --        inexact = (down) ? 1 : -1;
  2.1302 -+        inexact = (cmp_low > 0) ? -1 : 1;
  2.1303 -     }
  2.1304 -   else
  2.1305 -     inexact = 0;
  2.1306 -diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
  2.1307 ---- mpfr-3.0.0-a/tests/tfma.c	2010-06-10 11:00:13.000000000 +0000
  2.1308 -+++ mpfr-3.0.0-b/tests/tfma.c	2010-10-21 20:59:32.000000000 +0000
  2.1309 -@@ -337,6 +337,94 @@
  2.1310 -   mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
  2.1311 - }
  2.1312 - 
  2.1313 -+static void
  2.1314 -+bug20101018 (void)
  2.1315 -+{
  2.1316 -+  mpfr_t x, y, z, t, u;
  2.1317 -+  int i;
  2.1318 -+
  2.1319 -+  mpfr_init2 (x, 64);
  2.1320 -+  mpfr_init2 (y, 64);
  2.1321 -+  mpfr_init2 (z, 64);
  2.1322 -+  mpfr_init2 (t, 64);
  2.1323 -+  mpfr_init2 (u, 64);
  2.1324 -+
  2.1325 -+  mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
  2.1326 -+  mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
  2.1327 -+  mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
  2.1328 -+  mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
  2.1329 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  2.1330 -+  if (mpfr_cmp (u, t) != 0)
  2.1331 -+    {
  2.1332 -+      printf ("Wrong result in bug20101018 (a)\n");
  2.1333 -+      printf ("Expected ");
  2.1334 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  2.1335 -+      printf ("\nGot      ");
  2.1336 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  2.1337 -+      printf ("\n");
  2.1338 -+      exit (1);
  2.1339 -+    }
  2.1340 -+  if (i <= 0)
  2.1341 -+    {
  2.1342 -+      printf ("Wrong ternary value in bug20101018 (a)\n");
  2.1343 -+      printf ("Expected > 0\n");
  2.1344 -+      printf ("Got      %d\n", i);
  2.1345 -+      exit (1);
  2.1346 -+    }
  2.1347 -+
  2.1348 -+  mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
  2.1349 -+  mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
  2.1350 -+  mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
  2.1351 -+  mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
  2.1352 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  2.1353 -+  if (mpfr_cmp (u, t) != 0)
  2.1354 -+    {
  2.1355 -+      printf ("Wrong result in bug20101018 (b)\n");
  2.1356 -+      printf ("Expected ");
  2.1357 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  2.1358 -+      printf ("\nGot      ");
  2.1359 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  2.1360 -+      printf ("\n");
  2.1361 -+      exit (1);
  2.1362 -+    }
  2.1363 -+  if (i <= 0)
  2.1364 -+    {
  2.1365 -+      printf ("Wrong ternary value in bug20101018 (b)\n");
  2.1366 -+      printf ("Expected > 0\n");
  2.1367 -+      printf ("Got      %d\n", i);
  2.1368 -+      exit (1);
  2.1369 -+    }
  2.1370 -+
  2.1371 -+  mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
  2.1372 -+  mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
  2.1373 -+  mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
  2.1374 -+  mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
  2.1375 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  2.1376 -+  if (mpfr_cmp (u, t) != 0)
  2.1377 -+    {
  2.1378 -+      printf ("Wrong result in bug20101018 (c)\n");
  2.1379 -+      printf ("Expected ");
  2.1380 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  2.1381 -+      printf ("\nGot      ");
  2.1382 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  2.1383 -+      printf ("\n");
  2.1384 -+      exit (1);
  2.1385 -+    }
  2.1386 -+  if (i <= 0)
  2.1387 -+    {
  2.1388 -+      printf ("Wrong ternary value in bug20101018 (c)\n");
  2.1389 -+      printf ("Expected > 0\n");
  2.1390 -+      printf ("Got      %d\n", i);
  2.1391 -+      exit (1);
  2.1392 -+    }
  2.1393 -+
  2.1394 -+  mpfr_clear (x);
  2.1395 -+  mpfr_clear (y);
  2.1396 -+  mpfr_clear (z);
  2.1397 -+  mpfr_clear (t);
  2.1398 -+  mpfr_clear (u);
  2.1399 -+}
  2.1400 -+
  2.1401 - int
  2.1402 - main (int argc, char *argv[])
  2.1403 - {
  2.1404 -@@ -345,6 +433,8 @@
  2.1405 - 
  2.1406 -   tests_start_mpfr ();
  2.1407 - 
  2.1408 -+  bug20101018 ();
  2.1409 -+
  2.1410 -   mpfr_init (x);
  2.1411 -   mpfr_init (s);
  2.1412 -   mpfr_init (y);
  2.1413 -diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
  2.1414 ---- mpfr-3.0.0-a/tests/tsub.c	2010-06-10 11:00:13.000000000 +0000
  2.1415 -+++ mpfr-3.0.0-b/tests/tsub.c	2010-10-21 20:59:32.000000000 +0000
  2.1416 -@@ -201,6 +201,8 @@
  2.1417 -   if (mpfr_cmp (z, x))
  2.1418 -     {
  2.1419 -       printf ("Error in mpfr_sub (2)\n");
  2.1420 -+      printf ("Expected "); mpfr_print_binary (x); puts ("");
  2.1421 -+      printf ("Got      "); mpfr_print_binary (z); puts ("");
  2.1422 -       exit (1);
  2.1423 -     }
  2.1424 -   mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
  2.1425 -@@ -478,6 +480,156 @@
  2.1426 -   mpfr_clear (u);
  2.1427 - }
  2.1428 - 
  2.1429 -+/* Bug found by Jakub Jelinek
  2.1430 -+ * http://bugzilla.redhat.com/643657
  2.1431 -+ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
  2.1432 -+ * The consequence can be either an assertion failure (i = 2 in the
  2.1433 -+ * testcase below, in debug mode) or an incorrectly rounded value.
  2.1434 -+ */
  2.1435 -+static void
  2.1436 -+bug20101017 (void)
  2.1437 -+{
  2.1438 -+  mpfr_t a, b, c;
  2.1439 -+  int inex;
  2.1440 -+  int i;
  2.1441 -+
  2.1442 -+  mpfr_init2 (a, GMP_NUMB_BITS * 2);
  2.1443 -+  mpfr_init2 (b, GMP_NUMB_BITS);
  2.1444 -+  mpfr_init2 (c, GMP_NUMB_BITS);
  2.1445 -+
  2.1446 -+  /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
  2.1447 -+     with N = GMP_NUMB_BITS and k = 0 or 1.
  2.1448 -+     c = a - b should round to the same value as a. */
  2.1449 -+
  2.1450 -+  for (i = 2; i <= 3; i++)
  2.1451 -+    {
  2.1452 -+      mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
  2.1453 -+      mpfr_add_ui (a, a, 1, MPFR_RNDN);
  2.1454 -+      mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
  2.1455 -+      mpfr_set_ui (b, 1, MPFR_RNDN);
  2.1456 -+      inex = mpfr_sub (c, a, b, MPFR_RNDN);
  2.1457 -+      mpfr_set (b, a, MPFR_RNDN);
  2.1458 -+      if (! mpfr_equal_p (c, b))
  2.1459 -+        {
  2.1460 -+          printf ("Error in bug20101017 for i = %d.\n", i);
  2.1461 -+          printf ("Expected ");
  2.1462 -+          mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
  2.1463 -+          putchar ('\n');
  2.1464 -+          printf ("Got      ");
  2.1465 -+          mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
  2.1466 -+          putchar ('\n');
  2.1467 -+          exit (1);
  2.1468 -+        }
  2.1469 -+      if (inex >= 0)
  2.1470 -+        {
  2.1471 -+          printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
  2.1472 -+          printf ("Expected negative, got %d.\n", inex);
  2.1473 -+          exit (1);
  2.1474 -+        }
  2.1475 -+    }
  2.1476 -+
  2.1477 -+  mpfr_set_prec (a, 64);
  2.1478 -+  mpfr_set_prec (b, 129);
  2.1479 -+  mpfr_set_prec (c, 2);
  2.1480 -+  mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
  2.1481 -+  mpfr_set_str_binary (c, "0.10E1");
  2.1482 -+  inex = mpfr_sub (a, b, c, MPFR_RNDN);
  2.1483 -+  if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
  2.1484 -+    {
  2.1485 -+      printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
  2.1486 -+      printf ("Expected result 2^64 with inex < 0\n");
  2.1487 -+      printf ("Got "); mpfr_print_binary (a);
  2.1488 -+      printf (" with inex=%d\n", inex);
  2.1489 -+      exit (1);
  2.1490 -+    }
  2.1491 -+
  2.1492 -+  mpfr_clears (a, b, c, (mpfr_ptr) 0);
  2.1493 -+}
  2.1494 -+
  2.1495 -+/* hard test of rounding */
  2.1496 -+static void
  2.1497 -+check_rounding (void)
  2.1498 -+{
  2.1499 -+  mpfr_t a, b, c, res;
  2.1500 -+  mpfr_prec_t p;
  2.1501 -+  long k, l;
  2.1502 -+  int i;
  2.1503 -+
  2.1504 -+#define MAXKL (2 * GMP_NUMB_BITS)
  2.1505 -+  for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
  2.1506 -+    {
  2.1507 -+      mpfr_init2 (a, p);
  2.1508 -+      mpfr_init2 (res, p);
  2.1509 -+      mpfr_init2 (b, p + 1 + MAXKL);
  2.1510 -+      mpfr_init2 (c, MPFR_PREC_MIN);
  2.1511 -+
  2.1512 -+      /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
  2.1513 -+      for (k = 0; k <= MAXKL; k++)
  2.1514 -+        for (l = 0; l <= MAXKL; l++)
  2.1515 -+          {
  2.1516 -+            mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
  2.1517 -+            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  2.1518 -+            mpfr_mul_2ui (b, b, k, MPFR_RNDN);
  2.1519 -+            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  2.1520 -+            mpfr_div_2ui (b, b, k, MPFR_RNDN);
  2.1521 -+            mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
  2.1522 -+            i = mpfr_sub (a, b, c, MPFR_RNDN);
  2.1523 -+            /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
  2.1524 -+               2^p for l <= k, and 2^p+2 for l < k */
  2.1525 -+            if (l <= k)
  2.1526 -+              {
  2.1527 -+                if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
  2.1528 -+                  {
  2.1529 -+                    printf ("Wrong result in check_rounding\n");
  2.1530 -+                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  2.1531 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  2.1532 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  2.1533 -+                    printf ("Expected 2^%lu\n", p);
  2.1534 -+                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  2.1535 -+                    exit (1);
  2.1536 -+                  }
  2.1537 -+                if (i >= 0)
  2.1538 -+                  {
  2.1539 -+                    printf ("Wrong ternary value in check_rounding\n");
  2.1540 -+                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  2.1541 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  2.1542 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  2.1543 -+                    printf ("a="); mpfr_print_binary (a); puts ("");
  2.1544 -+                    printf ("Expected < 0, got %d\n", i);
  2.1545 -+                    exit (1);
  2.1546 -+                  }
  2.1547 -+              }
  2.1548 -+            else /* l < k */
  2.1549 -+              {
  2.1550 -+                mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
  2.1551 -+                mpfr_add_ui (res, res, 2, MPFR_RNDN);
  2.1552 -+                if (mpfr_cmp (a, res) != 0)
  2.1553 -+                  {
  2.1554 -+                    printf ("Wrong result in check_rounding\n");
  2.1555 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  2.1556 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  2.1557 -+                    printf ("Expected "); mpfr_print_binary (res); puts ("");
  2.1558 -+                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  2.1559 -+                    exit (1);
  2.1560 -+                  }
  2.1561 -+                if (i <= 0)
  2.1562 -+                  {
  2.1563 -+                    printf ("Wrong ternary value in check_rounding\n");
  2.1564 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  2.1565 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  2.1566 -+                    printf ("Expected > 0, got %d\n", i);
  2.1567 -+                    exit (1);
  2.1568 -+                  }
  2.1569 -+              }
  2.1570 -+          }
  2.1571 -+
  2.1572 -+      mpfr_clear (a);
  2.1573 -+      mpfr_clear (res);
  2.1574 -+      mpfr_clear (b);
  2.1575 -+      mpfr_clear (c);
  2.1576 -+    }
  2.1577 -+}
  2.1578 -+
  2.1579 - #define TEST_FUNCTION test_sub
  2.1580 - #define TWO_ARGS
  2.1581 - #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
  2.1582 -@@ -491,6 +643,8 @@
  2.1583 - 
  2.1584 -   tests_start_mpfr ();
  2.1585 - 
  2.1586 -+  bug20101017 ();
  2.1587 -+  check_rounding ();
  2.1588 -   check_diverse ();
  2.1589 -   check_inexact ();
  2.1590 -   bug_ddefour ();
  2.1591 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  2.1592 ---- mpfr-3.0.0-a/version.c	2010-10-21 20:28:38.000000000 +0000
  2.1593 -+++ mpfr-3.0.0-b/version.c	2010-10-21 20:59:32.000000000 +0000
  2.1594 -@@ -25,5 +25,5 @@
  2.1595 - const char *
  2.1596 - mpfr_get_version (void)
  2.1597 - {
  2.1598 --  return "3.0.0-p5";
  2.1599 -+  return "3.0.0-p6";
  2.1600 - }
  2.1601 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  2.1602 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 21:18:26.000000000 +0000
  2.1603 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 21:18:26.000000000 +0000
  2.1604 -@@ -0,0 +1 @@
  2.1605 -+mpfr_set_ld
  2.1606 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  2.1607 ---- mpfr-3.0.0-a/VERSION	2010-10-21 20:59:32.000000000 +0000
  2.1608 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 21:18:26.000000000 +0000
  2.1609 -@@ -1 +1 @@
  2.1610 --3.0.0-p6
  2.1611 -+3.0.0-p7
  2.1612 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  2.1613 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:59:32.000000000 +0000
  2.1614 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  2.1615 -@@ -27,7 +27,7 @@
  2.1616 - #define MPFR_VERSION_MAJOR 3
  2.1617 - #define MPFR_VERSION_MINOR 0
  2.1618 - #define MPFR_VERSION_PATCHLEVEL 0
  2.1619 --#define MPFR_VERSION_STRING "3.0.0-p6"
  2.1620 -+#define MPFR_VERSION_STRING "3.0.0-p7"
  2.1621 - 
  2.1622 - /* Macros dealing with MPFR VERSION */
  2.1623 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  2.1624 -diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
  2.1625 ---- mpfr-3.0.0-a/set_ld.c	2010-06-10 11:00:14.000000000 +0000
  2.1626 -+++ mpfr-3.0.0-b/set_ld.c	2010-10-21 21:18:26.000000000 +0000
  2.1627 -@@ -102,21 +102,25 @@
  2.1628 -             {
  2.1629 -               x /= div13; /* exact */
  2.1630 -               shift_exp += 8192;
  2.1631 -+              mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
  2.1632 -             }
  2.1633 -           if (ABS (x) >= div12)
  2.1634 -             {
  2.1635 -               x /= div12; /* exact */
  2.1636 -               shift_exp += 4096;
  2.1637 -+              mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
  2.1638 -             }
  2.1639 -           if (ABS (x) >= div11)
  2.1640 -             {
  2.1641 -               x /= div11; /* exact */
  2.1642 -               shift_exp += 2048;
  2.1643 -+              mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
  2.1644 -             }
  2.1645 -           if (ABS (x) >= div10)
  2.1646 -             {
  2.1647 -               x /= div10; /* exact */
  2.1648 -               shift_exp += 1024;
  2.1649 -+              mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
  2.1650 -             }
  2.1651 -           /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
  2.1652 -              therefore we have one extra exponent reduction step */
  2.1653 -@@ -124,9 +128,10 @@
  2.1654 -             {
  2.1655 -               x /= div9; /* exact */
  2.1656 -               shift_exp += 512;
  2.1657 -+              mpfr_div_2si (t, t, 512, MPFR_RNDZ);
  2.1658 -             }
  2.1659 -         } /* Check overflow of double */
  2.1660 --      else
  2.1661 -+      else /* no overflow on double */
  2.1662 -         {
  2.1663 -           long double div9, div10, div11;
  2.1664 - 
  2.1665 -@@ -149,29 +154,34 @@
  2.1666 -                 {
  2.1667 -                   x /= div13; /* exact */
  2.1668 -                   shift_exp -= 8192;
  2.1669 -+                  mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
  2.1670 -                 }
  2.1671 -               if (ABS (x) <= div12)
  2.1672 -                 {
  2.1673 -                   x /= div12; /* exact */
  2.1674 -                   shift_exp -= 4096;
  2.1675 -+                  mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
  2.1676 -                 }
  2.1677 -               if (ABS (x) <= div11)
  2.1678 -                 {
  2.1679 -                   x /= div11; /* exact */
  2.1680 -                   shift_exp -= 2048;
  2.1681 -+                  mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
  2.1682 -                 }
  2.1683 -               if (ABS (x) <= div10)
  2.1684 -                 {
  2.1685 -                   x /= div10; /* exact */
  2.1686 -                   shift_exp -= 1024;
  2.1687 -+                  mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
  2.1688 -                 }
  2.1689 -               if (ABS(x) <= div9)
  2.1690 -                 {
  2.1691 -                   x /= div9;  /* exact */
  2.1692 -                   shift_exp -= 512;
  2.1693 -+                  mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
  2.1694 -                 }
  2.1695 -             }
  2.1696 --          else
  2.1697 -+          else /* no underflow */
  2.1698 -             {
  2.1699 -               inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
  2.1700 -               MPFR_ASSERTD (inexact == 0);
  2.1701 -diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
  2.1702 ---- mpfr-3.0.0-a/tests/tset_ld.c	2010-06-10 11:00:13.000000000 +0000
  2.1703 -+++ mpfr-3.0.0-b/tests/tset_ld.c	2010-10-21 21:18:26.000000000 +0000
  2.1704 -@@ -147,12 +147,39 @@
  2.1705 - test_fixed_bugs (void)
  2.1706 - {
  2.1707 -   mpfr_t x;
  2.1708 --  long double d;
  2.1709 -+  long double l, m;
  2.1710 - 
  2.1711 -   /* bug found by Steve Kargl (2009-03-14) */
  2.1712 -   mpfr_init2 (x, 64);
  2.1713 -   mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
  2.1714 --  d = mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  2.1715 -+  mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  2.1716 -+
  2.1717 -+  /* bug reported by Jakub Jelinek (2010-10-17)
  2.1718 -+     https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
  2.1719 -+  mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
  2.1720 -+  /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
  2.1721 -+  l = 8.215640181713713164092636634579e-276;
  2.1722 -+  mpfr_set_ld (x, l, MPFR_RNDN);
  2.1723 -+  m = mpfr_get_ld (x, MPFR_RNDN);
  2.1724 -+  if (m != l)
  2.1725 -+    {
  2.1726 -+      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  2.1727 -+      printf ("Got m=%Le instead of l\n", m);
  2.1728 -+      exit (1);
  2.1729 -+    }
  2.1730 -+
  2.1731 -+  /* another similar test which failed with extended double precision and the
  2.1732 -+     generic code for mpfr_set_ld */
  2.1733 -+  /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
  2.1734 -+  l = 4.560596445887084662336528403703e-292;
  2.1735 -+  mpfr_set_ld (x, l, MPFR_RNDN);
  2.1736 -+  m = mpfr_get_ld (x, MPFR_RNDN);
  2.1737 -+  if (m != l)
  2.1738 -+    {
  2.1739 -+      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  2.1740 -+      printf ("Got m=%Le instead of l\n", m);
  2.1741 -+      exit (1);
  2.1742 -+    }
  2.1743 - 
  2.1744 -   mpfr_clear (x);
  2.1745 - }
  2.1746 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  2.1747 ---- mpfr-3.0.0-a/version.c	2010-10-21 20:59:32.000000000 +0000
  2.1748 -+++ mpfr-3.0.0-b/version.c	2010-10-21 21:18:26.000000000 +0000
  2.1749 -@@ -25,5 +25,5 @@
  2.1750 - const char *
  2.1751 - mpfr_get_version (void)
  2.1752 - {
  2.1753 --  return "3.0.0-p6";
  2.1754 -+  return "3.0.0-p7";
  2.1755 - }
  2.1756 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  2.1757 ---- mpfr-3.0.0-a/PATCHES	2010-11-09 15:15:07.000000000 +0000
  2.1758 -+++ mpfr-3.0.0-b/PATCHES	2010-11-09 15:15:07.000000000 +0000
  2.1759 -@@ -0,0 +1 @@
  2.1760 -+macros
  2.1761 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  2.1762 ---- mpfr-3.0.0-a/VERSION	2010-10-21 21:18:26.000000000 +0000
  2.1763 -+++ mpfr-3.0.0-b/VERSION	2010-11-09 15:15:07.000000000 +0000
  2.1764 -@@ -1 +1 @@
  2.1765 --3.0.0-p7
  2.1766 -+3.0.0-p8
  2.1767 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  2.1768 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  2.1769 -+++ mpfr-3.0.0-b/mpfr.h	2010-11-09 15:15:07.000000000 +0000
  2.1770 -@@ -27,7 +27,7 @@
  2.1771 - #define MPFR_VERSION_MAJOR 3
  2.1772 - #define MPFR_VERSION_MINOR 0
  2.1773 - #define MPFR_VERSION_PATCHLEVEL 0
  2.1774 --#define MPFR_VERSION_STRING "3.0.0-p7"
  2.1775 -+#define MPFR_VERSION_STRING "3.0.0-p8"
  2.1776 - 
  2.1777 - /* Macros dealing with MPFR VERSION */
  2.1778 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  2.1779 -@@ -67,6 +67,16 @@
  2.1780 - # define _MPFR_H_HAVE_INTMAX_T 1
  2.1781 - #endif
  2.1782 - 
  2.1783 -+/* Avoid some problems with macro expansion if the user defines macros
  2.1784 -+   with the same name as keywords. By convention, identifiers and macro
  2.1785 -+   names starting with mpfr_ are reserved by MPFR. */
  2.1786 -+typedef void            mpfr_void;
  2.1787 -+typedef int             mpfr_int;
  2.1788 -+typedef unsigned int    mpfr_uint;
  2.1789 -+typedef long            mpfr_long;
  2.1790 -+typedef unsigned long   mpfr_ulong;
  2.1791 -+typedef size_t          mpfr_size_t;
  2.1792 -+
  2.1793 - /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
  2.1794 -    Warning! Changing the contents of this enum should be seen as an
  2.1795 -    interface change since the old and the new types are not compatible
  2.1796 -@@ -136,7 +146,7 @@
  2.1797 - typedef mp_exp_t     mpfr_exp_t;
  2.1798 - 
  2.1799 - /* Definition of the standard exponent limits */
  2.1800 --#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
  2.1801 -+#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
  2.1802 - #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
  2.1803 - 
  2.1804 - /* Definition of the main structure */
  2.1805 -@@ -725,13 +735,13 @@
  2.1806 -    unexpected results with future compilers and aggressive optimisations.
  2.1807 -    Why not working only with signed types, using INT_MIN and LONG_MIN? */
  2.1808 - #if __GMP_MP_SIZE_T_INT
  2.1809 --#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
  2.1810 --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
  2.1811 --#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
  2.1812 -+#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
  2.1813 -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
  2.1814 -+#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
  2.1815 - #else
  2.1816 --#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
  2.1817 --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
  2.1818 --#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
  2.1819 -+#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
  2.1820 -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
  2.1821 -+#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
  2.1822 - #endif
  2.1823 - 
  2.1824 - /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
  2.1825 -@@ -760,9 +770,9 @@
  2.1826 - #define mpfr_inf_p(_x)      ((_x)->_mpfr_exp == __MPFR_EXP_INF)
  2.1827 - #define mpfr_zero_p(_x)     ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
  2.1828 - #define mpfr_regular_p(_x)  ((_x)->_mpfr_exp >  __MPFR_EXP_INF)
  2.1829 --#define mpfr_sgn(_x)                                          \
  2.1830 --  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
  2.1831 --   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
  2.1832 -+#define mpfr_sgn(_x)                                               \
  2.1833 -+  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                              \
  2.1834 -+   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
  2.1835 -    MPFR_SIGN (_x))
  2.1836 - 
  2.1837 - /* Prevent them from using as lvalues */
  2.1838 -@@ -805,7 +815,19 @@
  2.1839 -    Moreover casts to unsigned long have been added to avoid warnings in
  2.1840 -    programs that use MPFR and are compiled with -Wconversion; such casts
  2.1841 -    are OK since if X is a constant expression, then (unsigned long) X is
  2.1842 --   also a constant expression, so that the optimizations still work. */
  2.1843 -+   also a constant expression, so that the optimizations still work. The
  2.1844 -+   warnings are probably related to the following two bugs:
  2.1845 -+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
  2.1846 -+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
  2.1847 -+   and the casts could be removed once these bugs are fixed.
  2.1848 -+   Casts shouldn't be used on the generic calls (to the ..._2exp functions),
  2.1849 -+   where implicit conversions are performed. Indeed, having at least one
  2.1850 -+   implicit conversion in the macro allows the compiler to emit diagnostics
  2.1851 -+   when normally expected, for instance in the following call:
  2.1852 -+     mpfr_set_ui (x, "foo", MPFR_RNDN);
  2.1853 -+   If this is not possible (for future macros), one of the tricks described
  2.1854 -+   on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
  2.1855 -+   be used. */
  2.1856 - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
  2.1857 - #if (__GNUC__ >= 2)
  2.1858 - #undef mpfr_cmp_ui
  2.1859 -@@ -813,45 +835,45 @@
  2.1860 -    But warning! mpfr_sgn is specified as a macro in the API, thus the macro
  2.1861 -    mustn't be used if side effects are possible, like here. */
  2.1862 - #define mpfr_cmp_ui(_f,_u)                                      \
  2.1863 --  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  2.1864 -+  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  2.1865 -    (mpfr_sgn) (_f) :                                            \
  2.1866 --   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
  2.1867 -+   mpfr_cmp_ui_2exp ((_f), (_u), 0))
  2.1868 - #undef mpfr_cmp_si
  2.1869 --#define mpfr_cmp_si(_f,_s)                              \
  2.1870 --  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
  2.1871 --   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
  2.1872 --   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
  2.1873 -+#define mpfr_cmp_si(_f,_s)                                      \
  2.1874 -+  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  2.1875 -+   mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) :          \
  2.1876 -+   mpfr_cmp_si_2exp ((_f), (_s), 0))
  2.1877 - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
  2.1878 - #undef mpfr_set_ui
  2.1879 - #define mpfr_set_ui(_f,_u,_r)                                   \
  2.1880 --  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  2.1881 -+  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  2.1882 -    __extension__ ({                                             \
  2.1883 -        mpfr_ptr _p = (_f);                                      \
  2.1884 -        _p->_mpfr_sign = 1;                                      \
  2.1885 -        _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
  2.1886 --       (void) (_r); 0; }) :                                     \
  2.1887 --   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
  2.1888 -+       (mpfr_void) (_r); 0; }) :                                \
  2.1889 -+   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
  2.1890 - #endif
  2.1891 - #undef mpfr_set_si
  2.1892 - #define mpfr_set_si(_f,_s,_r)                                   \
  2.1893 --  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
  2.1894 --   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
  2.1895 --   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
  2.1896 -+  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  2.1897 -+   mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) :    \
  2.1898 -+   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
  2.1899 - #endif
  2.1900 - #endif
  2.1901 - 
  2.1902 - /* Macro version of mpfr_stack interface for fast access */
  2.1903 --#define mpfr_custom_get_size(p) ((size_t)                            \
  2.1904 -+#define mpfr_custom_get_size(p) ((mpfr_size_t)                          \
  2.1905 -        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
  2.1906 - #define mpfr_custom_init(m,p) do {} while (0)
  2.1907 --#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
  2.1908 -+#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
  2.1909 - #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
  2.1910 - #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
  2.1911 - #define mpfr_custom_init_set(x,k,e,p,m) do {                   \
  2.1912 -   mpfr_ptr _x = (x);                                           \
  2.1913 -   mpfr_exp_t _e;                                               \
  2.1914 -   mpfr_kind_t _t;                                              \
  2.1915 --  int _s, _k;                                                  \
  2.1916 -+  mpfr_int _s, _k;                                             \
  2.1917 -   _k = (k);                                                    \
  2.1918 -   if (_k >= 0)  {                                              \
  2.1919 -     _t = (mpfr_kind_t) _k;                                     \
  2.1920 -@@ -868,11 +890,13 @@
  2.1921 -   _x->_mpfr_exp  = _e;                                         \
  2.1922 -   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
  2.1923 -  } while (0)
  2.1924 --#define mpfr_custom_get_kind(x)                                              \
  2.1925 --  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
  2.1926 --  : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
  2.1927 --  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
  2.1928 --  : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  2.1929 -+#define mpfr_custom_get_kind(x)                                         \
  2.1930 -+  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ?                                  \
  2.1931 -+    (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x)                        \
  2.1932 -+  : (x)->_mpfr_exp == __MPFR_EXP_INF ?                                  \
  2.1933 -+    (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x)                            \
  2.1934 -+  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND         \
  2.1935 -+  : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  2.1936 - 
  2.1937 - 
  2.1938 - #endif /* MPFR_USE_NO_MACRO */
  2.1939 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  2.1940 ---- mpfr-3.0.0-a/version.c	2010-10-21 21:18:26.000000000 +0000
  2.1941 -+++ mpfr-3.0.0-b/version.c	2010-11-09 15:15:07.000000000 +0000
  2.1942 -@@ -25,5 +25,5 @@
  2.1943 - const char *
  2.1944 - mpfr_get_version (void)
  2.1945 - {
  2.1946 --  return "3.0.0-p7";
  2.1947 -+  return "3.0.0-p8";
  2.1948 - }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/mpfr/stuff/mpfr-3.0.0.patch	Wed May 11 00:48:49 2011 +0200
     3.3 @@ -0,0 +1,1945 @@
     3.4 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
     3.5 +--- mpfr-3.0.0-a/PATCHES	2010-06-23 11:02:49.000000000 +0000
     3.6 ++++ mpfr-3.0.0-b/PATCHES	2010-06-23 11:03:36.000000000 +0000
     3.7 +@@ -0,0 +1 @@
     3.8 ++mpfr_out_str
     3.9 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
    3.10 +--- mpfr-3.0.0-a/VERSION	2010-06-10 11:00:14.000000000 +0000
    3.11 ++++ mpfr-3.0.0-b/VERSION	2010-06-23 11:03:20.000000000 +0000
    3.12 +@@ -1 +1 @@
    3.13 +-3.0.0
    3.14 ++3.0.0-p1
    3.15 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
    3.16 +--- mpfr-3.0.0-a/mpfr.h	2010-06-10 11:00:14.000000000 +0000
    3.17 ++++ mpfr-3.0.0-b/mpfr.h	2010-06-23 11:03:20.000000000 +0000
    3.18 +@@ -27,7 +27,7 @@
    3.19 + #define MPFR_VERSION_MAJOR 3
    3.20 + #define MPFR_VERSION_MINOR 0
    3.21 + #define MPFR_VERSION_PATCHLEVEL 0
    3.22 +-#define MPFR_VERSION_STRING "3.0.0"
    3.23 ++#define MPFR_VERSION_STRING "3.0.0-p1"
    3.24 + 
    3.25 + /* Macros dealing with MPFR VERSION */
    3.26 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    3.27 +diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
    3.28 +--- mpfr-3.0.0-a/mpfr.texi	2010-06-10 11:00:14.000000000 +0000
    3.29 ++++ mpfr-3.0.0-b/mpfr.texi	2010-06-23 11:03:12.000000000 +0000
    3.30 +@@ -2050,7 +2050,7 @@
    3.31 + are printed. If @var{base} is greater than 10, @samp{@@} will be used
    3.32 + instead of @samp{e} as exponent delimiter.
    3.33 + 
    3.34 +-Return the number of bytes written, or if an error occurred, return 0.
    3.35 ++Return the number of characters written, or if an error occurred, return 0.
    3.36 + @end deftypefun
    3.37 + 
    3.38 + @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
    3.39 +diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
    3.40 +--- mpfr-3.0.0-a/out_str.c	2010-06-10 11:00:14.000000000 +0000
    3.41 ++++ mpfr-3.0.0-b/out_str.c	2010-06-23 11:03:12.000000000 +0000
    3.42 +@@ -22,6 +22,16 @@
    3.43 + 
    3.44 + #include "mpfr-impl.h"
    3.45 + 
    3.46 ++/* Warning! S should not contain "%". */
    3.47 ++#define OUT_STR_RET(S)                          \
    3.48 ++  do                                            \
    3.49 ++    {                                           \
    3.50 ++      int r;                                    \
    3.51 ++      r = fprintf (stream, (S));                \
    3.52 ++      return r < 0 ? 0 : r;                     \
    3.53 ++    }                                           \
    3.54 ++  while (0)
    3.55 ++
    3.56 + size_t
    3.57 + mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
    3.58 +               mpfr_rnd_t rnd_mode)
    3.59 +@@ -29,6 +39,7 @@
    3.60 +   char *s, *s0;
    3.61 +   size_t l;
    3.62 +   mpfr_exp_t e;
    3.63 ++  int err;
    3.64 + 
    3.65 +   MPFR_ASSERTN (base >= 2 && base <= 62);
    3.66 + 
    3.67 +@@ -36,37 +47,16 @@
    3.68 +   if (stream == NULL)
    3.69 +     stream = stdout;
    3.70 + 
    3.71 +-  if (MPFR_IS_NAN(op))
    3.72 +-    {
    3.73 +-      fprintf (stream, "@NaN@");
    3.74 +-      return 3;
    3.75 +-    }
    3.76 +-
    3.77 +-  if (MPFR_IS_INF(op))
    3.78 +-    {
    3.79 +-      if (MPFR_SIGN(op) > 0)
    3.80 +-        {
    3.81 +-          fprintf (stream, "@Inf@");
    3.82 +-          return 3;
    3.83 +-        }
    3.84 +-      else
    3.85 +-        {
    3.86 +-          fprintf (stream, "-@Inf@");
    3.87 +-          return 4;
    3.88 +-        }
    3.89 +-    }
    3.90 +-
    3.91 +-  if (MPFR_IS_ZERO(op))
    3.92 ++  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
    3.93 +     {
    3.94 +-      if (MPFR_SIGN(op) > 0)
    3.95 +-        {
    3.96 +-          fprintf(stream, "0");
    3.97 +-          return 1;
    3.98 +-        }
    3.99 ++      if (MPFR_IS_NAN (op))
   3.100 ++        OUT_STR_RET ("@NaN@");
   3.101 ++      else if (MPFR_IS_INF (op))
   3.102 ++        OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
   3.103 +       else
   3.104 +         {
   3.105 +-          fprintf(stream, "-0");
   3.106 +-          return 2;
   3.107 ++          MPFR_ASSERTD (MPFR_IS_ZERO (op));
   3.108 ++          OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
   3.109 +         }
   3.110 +     }
   3.111 + 
   3.112 +@@ -77,21 +67,31 @@
   3.113 + 
   3.114 +   l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
   3.115 +                          - may be incorrect, as only an upper bound? */
   3.116 +-  if (*s == '-')
   3.117 +-    fputc (*s++, stream);
   3.118 + 
   3.119 +-  /* outputs mantissa */
   3.120 +-  fputc (*s++, stream); e--; /* leading digit */
   3.121 +-  fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
   3.122 +-  fputs (s, stream);         /* rest of mantissa */
   3.123 ++  /* outputs possible sign and significand */
   3.124 ++  err = (*s == '-' && fputc (*s++, stream) == EOF)
   3.125 ++    || fputc (*s++, stream) == EOF  /* leading digit */
   3.126 ++    || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
   3.127 ++    || fputs (s, stream) == EOF;     /* trailing significand */
   3.128 +   (*__gmp_free_func) (s0, l);
   3.129 ++  if (MPFR_UNLIKELY (err))
   3.130 ++    return 0;
   3.131 ++
   3.132 ++  e--;  /* due to the leading digit */
   3.133 + 
   3.134 +   /* outputs exponent */
   3.135 +   if (e)
   3.136 +     {
   3.137 ++      int r;
   3.138 ++
   3.139 +       MPFR_ASSERTN(e >= LONG_MIN);
   3.140 +       MPFR_ASSERTN(e <= LONG_MAX);
   3.141 +-      l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   3.142 ++
   3.143 ++      r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   3.144 ++      if (MPFR_UNLIKELY (r < 0))
   3.145 ++        return 0;
   3.146 ++
   3.147 ++      l += r;
   3.148 +     }
   3.149 + 
   3.150 +   return l;
   3.151 +diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
   3.152 +--- mpfr-3.0.0-a/tests/tout_str.c	2010-06-10 11:00:13.000000000 +0000
   3.153 ++++ mpfr-3.0.0-b/tests/tout_str.c	2010-06-23 11:03:12.000000000 +0000
   3.154 +@@ -46,22 +46,54 @@
   3.155 + special (void)
   3.156 + {
   3.157 +   mpfr_t x;
   3.158 ++  unsigned int n;
   3.159 + 
   3.160 +   mpfr_init (x);
   3.161 + 
   3.162 +   mpfr_set_nan (x);
   3.163 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.164 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.165 ++  if (n != 5)
   3.166 ++    {
   3.167 ++      printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
   3.168 ++              "characters instead of 5.\n", n);
   3.169 ++      exit (1);
   3.170 ++    }
   3.171 + 
   3.172 +   mpfr_set_inf (x, 1);
   3.173 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.174 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.175 ++  if (n != 5)
   3.176 ++    {
   3.177 ++      printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
   3.178 ++               "characters instead of 5.\n", n);
   3.179 ++      exit (1);
   3.180 ++    }
   3.181 + 
   3.182 +   mpfr_set_inf (x, -1);
   3.183 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.184 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.185 ++  if (n != 6)
   3.186 ++    {
   3.187 ++      printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
   3.188 ++               "characters instead of 6.\n", n);
   3.189 ++      exit (1);
   3.190 ++    }
   3.191 + 
   3.192 +   mpfr_set_ui (x, 0, MPFR_RNDN);
   3.193 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.194 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.195 ++  if (n != 1)
   3.196 ++    {
   3.197 ++      printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
   3.198 ++               "characters instead of 1.\n", n);
   3.199 ++      exit (1);
   3.200 ++    }
   3.201 ++
   3.202 +   mpfr_neg (x, x, MPFR_RNDN);
   3.203 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.204 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.205 ++  if (n != 2)
   3.206 ++    {
   3.207 ++      printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
   3.208 ++               "characters instead of 2.\n", n);
   3.209 ++      exit (1);
   3.210 ++    }
   3.211 + 
   3.212 +   mpfr_clear (x);
   3.213 + }
   3.214 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.215 +--- mpfr-3.0.0-a/version.c	2010-06-10 11:00:14.000000000 +0000
   3.216 ++++ mpfr-3.0.0-b/version.c	2010-06-23 11:03:20.000000000 +0000
   3.217 +@@ -25,5 +25,5 @@
   3.218 + const char *
   3.219 + mpfr_get_version (void)
   3.220 + {
   3.221 +-  return "3.0.0";
   3.222 ++  return "3.0.0-p1";
   3.223 + }
   3.224 +diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
   3.225 +--- mpfr-3.0.0-a/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.226 ++++ mpfr-3.0.0-b/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.227 +@@ -239,6 +239,7 @@
   3.228 + distuninstallcheck_listfiles = find . -type f -print
   3.229 + distcleancheck_listfiles = find . -type f -print
   3.230 + ACLOCAL = @ACLOCAL@
   3.231 ++ALLOCA = @ALLOCA@
   3.232 + AMTAR = @AMTAR@
   3.233 + AR = @AR@
   3.234 + AS = @AS@
   3.235 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.236 +--- mpfr-3.0.0-a/PATCHES	2010-06-23 11:03:36.000000000 +0000
   3.237 ++++ mpfr-3.0.0-b/PATCHES	2010-06-25 13:23:13.000000000 +0000
   3.238 +@@ -0,0 +1 @@
   3.239 ++alloca
   3.240 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.241 +--- mpfr-3.0.0-a/VERSION	2010-06-23 11:03:20.000000000 +0000
   3.242 ++++ mpfr-3.0.0-b/VERSION	2010-06-25 13:23:13.000000000 +0000
   3.243 +@@ -1 +1 @@
   3.244 +-3.0.0-p1
   3.245 ++3.0.0-p2
   3.246 +diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
   3.247 +--- mpfr-3.0.0-a/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   3.248 ++++ mpfr-3.0.0-b/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   3.249 +@@ -59,6 +59,9 @@
   3.250 + dnl sys/fpu.h - MIPS specific
   3.251 + AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
   3.252 + 
   3.253 ++dnl Check how to get `alloca'
   3.254 ++AC_FUNC_ALLOCA
   3.255 ++
   3.256 + dnl SIZE_MAX macro
   3.257 + gl_SIZE_MAX
   3.258 + 
   3.259 +diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
   3.260 +--- mpfr-3.0.0-a/configure	2010-06-10 11:00:51.000000000 +0000
   3.261 ++++ mpfr-3.0.0-b/configure	2010-06-25 13:23:05.000000000 +0000
   3.262 +@@ -783,6 +783,7 @@
   3.263 + OBJDUMP
   3.264 + DLLTOOL
   3.265 + AS
   3.266 ++ALLOCA
   3.267 + MPFR_LIBM
   3.268 + ANSI2KNR
   3.269 + U
   3.270 +@@ -5622,6 +5623,197 @@
   3.271 + done
   3.272 + 
   3.273 + 
   3.274 ++# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
   3.275 ++# for constant arguments.  Useless!
   3.276 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
   3.277 ++$as_echo_n "checking for working alloca.h... " >&6; }
   3.278 ++if test "${ac_cv_working_alloca_h+set}" = set; then :
   3.279 ++  $as_echo_n "(cached) " >&6
   3.280 ++else
   3.281 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.282 ++/* end confdefs.h.  */
   3.283 ++#include <alloca.h>
   3.284 ++int
   3.285 ++main ()
   3.286 ++{
   3.287 ++char *p = (char *) alloca (2 * sizeof (int));
   3.288 ++			  if (p) return 0;
   3.289 ++  ;
   3.290 ++  return 0;
   3.291 ++}
   3.292 ++_ACEOF
   3.293 ++if ac_fn_c_try_link "$LINENO"; then :
   3.294 ++  ac_cv_working_alloca_h=yes
   3.295 ++else
   3.296 ++  ac_cv_working_alloca_h=no
   3.297 ++fi
   3.298 ++rm -f core conftest.err conftest.$ac_objext \
   3.299 ++    conftest$ac_exeext conftest.$ac_ext
   3.300 ++fi
   3.301 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
   3.302 ++$as_echo "$ac_cv_working_alloca_h" >&6; }
   3.303 ++if test $ac_cv_working_alloca_h = yes; then
   3.304 ++
   3.305 ++$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
   3.306 ++
   3.307 ++fi
   3.308 ++
   3.309 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
   3.310 ++$as_echo_n "checking for alloca... " >&6; }
   3.311 ++if test "${ac_cv_func_alloca_works+set}" = set; then :
   3.312 ++  $as_echo_n "(cached) " >&6
   3.313 ++else
   3.314 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.315 ++/* end confdefs.h.  */
   3.316 ++#ifdef __GNUC__
   3.317 ++# define alloca __builtin_alloca
   3.318 ++#else
   3.319 ++# ifdef _MSC_VER
   3.320 ++#  include <malloc.h>
   3.321 ++#  define alloca _alloca
   3.322 ++# else
   3.323 ++#  ifdef HAVE_ALLOCA_H
   3.324 ++#   include <alloca.h>
   3.325 ++#  else
   3.326 ++#   ifdef _AIX
   3.327 ++ #pragma alloca
   3.328 ++#   else
   3.329 ++#    ifndef alloca /* predefined by HP cc +Olibcalls */
   3.330 ++char *alloca ();
   3.331 ++#    endif
   3.332 ++#   endif
   3.333 ++#  endif
   3.334 ++# endif
   3.335 ++#endif
   3.336 ++
   3.337 ++int
   3.338 ++main ()
   3.339 ++{
   3.340 ++char *p = (char *) alloca (1);
   3.341 ++				    if (p) return 0;
   3.342 ++  ;
   3.343 ++  return 0;
   3.344 ++}
   3.345 ++_ACEOF
   3.346 ++if ac_fn_c_try_link "$LINENO"; then :
   3.347 ++  ac_cv_func_alloca_works=yes
   3.348 ++else
   3.349 ++  ac_cv_func_alloca_works=no
   3.350 ++fi
   3.351 ++rm -f core conftest.err conftest.$ac_objext \
   3.352 ++    conftest$ac_exeext conftest.$ac_ext
   3.353 ++fi
   3.354 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
   3.355 ++$as_echo "$ac_cv_func_alloca_works" >&6; }
   3.356 ++
   3.357 ++if test $ac_cv_func_alloca_works = yes; then
   3.358 ++
   3.359 ++$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
   3.360 ++
   3.361 ++else
   3.362 ++  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
   3.363 ++# that cause trouble.  Some versions do not even contain alloca or
   3.364 ++# contain a buggy version.  If you still want to use their alloca,
   3.365 ++# use ar to extract alloca.o from them instead of compiling alloca.c.
   3.366 ++
   3.367 ++ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
   3.368 ++
   3.369 ++$as_echo "#define C_ALLOCA 1" >>confdefs.h
   3.370 ++
   3.371 ++
   3.372 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
   3.373 ++$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
   3.374 ++if test "${ac_cv_os_cray+set}" = set; then :
   3.375 ++  $as_echo_n "(cached) " >&6
   3.376 ++else
   3.377 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.378 ++/* end confdefs.h.  */
   3.379 ++#if defined CRAY && ! defined CRAY2
   3.380 ++webecray
   3.381 ++#else
   3.382 ++wenotbecray
   3.383 ++#endif
   3.384 ++
   3.385 ++_ACEOF
   3.386 ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   3.387 ++  $EGREP "webecray" >/dev/null 2>&1; then :
   3.388 ++  ac_cv_os_cray=yes
   3.389 ++else
   3.390 ++  ac_cv_os_cray=no
   3.391 ++fi
   3.392 ++rm -f conftest*
   3.393 ++
   3.394 ++fi
   3.395 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
   3.396 ++$as_echo "$ac_cv_os_cray" >&6; }
   3.397 ++if test $ac_cv_os_cray = yes; then
   3.398 ++  for ac_func in _getb67 GETB67 getb67; do
   3.399 ++    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   3.400 ++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   3.401 ++eval as_val=\$$as_ac_var
   3.402 ++   if test "x$as_val" = x""yes; then :
   3.403 ++
   3.404 ++cat >>confdefs.h <<_ACEOF
   3.405 ++#define CRAY_STACKSEG_END $ac_func
   3.406 ++_ACEOF
   3.407 ++
   3.408 ++    break
   3.409 ++fi
   3.410 ++
   3.411 ++  done
   3.412 ++fi
   3.413 ++
   3.414 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
   3.415 ++$as_echo_n "checking stack direction for C alloca... " >&6; }
   3.416 ++if test "${ac_cv_c_stack_direction+set}" = set; then :
   3.417 ++  $as_echo_n "(cached) " >&6
   3.418 ++else
   3.419 ++  if test "$cross_compiling" = yes; then :
   3.420 ++  ac_cv_c_stack_direction=0
   3.421 ++else
   3.422 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.423 ++/* end confdefs.h.  */
   3.424 ++$ac_includes_default
   3.425 ++int
   3.426 ++find_stack_direction ()
   3.427 ++{
   3.428 ++  static char *addr = 0;
   3.429 ++  auto char dummy;
   3.430 ++  if (addr == 0)
   3.431 ++    {
   3.432 ++      addr = &dummy;
   3.433 ++      return find_stack_direction ();
   3.434 ++    }
   3.435 ++  else
   3.436 ++    return (&dummy > addr) ? 1 : -1;
   3.437 ++}
   3.438 ++
   3.439 ++int
   3.440 ++main ()
   3.441 ++{
   3.442 ++  return find_stack_direction () < 0;
   3.443 ++}
   3.444 ++_ACEOF
   3.445 ++if ac_fn_c_try_run "$LINENO"; then :
   3.446 ++  ac_cv_c_stack_direction=1
   3.447 ++else
   3.448 ++  ac_cv_c_stack_direction=-1
   3.449 ++fi
   3.450 ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   3.451 ++  conftest.$ac_objext conftest.beam conftest.$ac_ext
   3.452 ++fi
   3.453 ++
   3.454 ++fi
   3.455 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
   3.456 ++$as_echo "$ac_cv_c_stack_direction" >&6; }
   3.457 ++cat >>confdefs.h <<_ACEOF
   3.458 ++#define STACK_DIRECTION $ac_cv_c_stack_direction
   3.459 ++_ACEOF
   3.460 ++
   3.461 ++
   3.462 ++fi
   3.463 ++
   3.464 ++
   3.465 + 
   3.466 +   for ac_header in stdint.h
   3.467 + do :
   3.468 +@@ -7564,13 +7756,13 @@
   3.469 + else
   3.470 +   lt_cv_nm_interface="BSD nm"
   3.471 +   echo "int some_variable = 0;" > conftest.$ac_ext
   3.472 +-  (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
   3.473 ++  (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
   3.474 +   (eval "$ac_compile" 2>conftest.err)
   3.475 +   cat conftest.err >&5
   3.476 +-  (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   3.477 ++  (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   3.478 +   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   3.479 +   cat conftest.err >&5
   3.480 +-  (eval echo "\"\$as_me:7573: output\"" >&5)
   3.481 ++  (eval echo "\"\$as_me:7765: output\"" >&5)
   3.482 +   cat conftest.out >&5
   3.483 +   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
   3.484 +     lt_cv_nm_interface="MS dumpbin"
   3.485 +@@ -8772,7 +8964,7 @@
   3.486 +   ;;
   3.487 + *-*-irix6*)
   3.488 +   # Find out which ABI we are using.
   3.489 +-  echo '#line 8775 "configure"' > conftest.$ac_ext
   3.490 ++  echo '#line 8967 "configure"' > conftest.$ac_ext
   3.491 +   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   3.492 +   (eval $ac_compile) 2>&5
   3.493 +   ac_status=$?
   3.494 +@@ -10032,11 +10224,11 @@
   3.495 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.496 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.497 +    -e 's:$: $lt_compiler_flag:'`
   3.498 +-   (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
   3.499 ++   (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
   3.500 +    (eval "$lt_compile" 2>conftest.err)
   3.501 +    ac_status=$?
   3.502 +    cat conftest.err >&5
   3.503 +-   echo "$as_me:10039: \$? = $ac_status" >&5
   3.504 ++   echo "$as_me:10231: \$? = $ac_status" >&5
   3.505 +    if (exit $ac_status) && test -s "$ac_outfile"; then
   3.506 +      # The compiler can only warn and ignore the option if not recognized
   3.507 +      # So say no if there are warnings other than the usual output.
   3.508 +@@ -10371,11 +10563,11 @@
   3.509 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.510 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.511 +    -e 's:$: $lt_compiler_flag:'`
   3.512 +-   (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
   3.513 ++   (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
   3.514 +    (eval "$lt_compile" 2>conftest.err)
   3.515 +    ac_status=$?
   3.516 +    cat conftest.err >&5
   3.517 +-   echo "$as_me:10378: \$? = $ac_status" >&5
   3.518 ++   echo "$as_me:10570: \$? = $ac_status" >&5
   3.519 +    if (exit $ac_status) && test -s "$ac_outfile"; then
   3.520 +      # The compiler can only warn and ignore the option if not recognized
   3.521 +      # So say no if there are warnings other than the usual output.
   3.522 +@@ -10476,11 +10668,11 @@
   3.523 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.524 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.525 +    -e 's:$: $lt_compiler_flag:'`
   3.526 +-   (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
   3.527 ++   (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
   3.528 +    (eval "$lt_compile" 2>out/conftest.err)
   3.529 +    ac_status=$?
   3.530 +    cat out/conftest.err >&5
   3.531 +-   echo "$as_me:10483: \$? = $ac_status" >&5
   3.532 ++   echo "$as_me:10675: \$? = $ac_status" >&5
   3.533 +    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   3.534 +    then
   3.535 +      # The compiler can only warn and ignore the option if not recognized
   3.536 +@@ -10531,11 +10723,11 @@
   3.537 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.538 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.539 +    -e 's:$: $lt_compiler_flag:'`
   3.540 +-   (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
   3.541 ++   (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
   3.542 +    (eval "$lt_compile" 2>out/conftest.err)
   3.543 +    ac_status=$?
   3.544 +    cat out/conftest.err >&5
   3.545 +-   echo "$as_me:10538: \$? = $ac_status" >&5
   3.546 ++   echo "$as_me:10730: \$? = $ac_status" >&5
   3.547 +    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   3.548 +    then
   3.549 +      # The compiler can only warn and ignore the option if not recognized
   3.550 +@@ -12915,7 +13107,7 @@
   3.551 +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   3.552 +   lt_status=$lt_dlunknown
   3.553 +   cat > conftest.$ac_ext <<_LT_EOF
   3.554 +-#line 12918 "configure"
   3.555 ++#line 13110 "configure"
   3.556 + #include "confdefs.h"
   3.557 + 
   3.558 + #if HAVE_DLFCN_H
   3.559 +@@ -13011,7 +13203,7 @@
   3.560 +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   3.561 +   lt_status=$lt_dlunknown
   3.562 +   cat > conftest.$ac_ext <<_LT_EOF
   3.563 +-#line 13014 "configure"
   3.564 ++#line 13206 "configure"
   3.565 + #include "confdefs.h"
   3.566 + 
   3.567 + #if HAVE_DLFCN_H
   3.568 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.569 +--- mpfr-3.0.0-a/mpfr.h	2010-06-23 11:03:20.000000000 +0000
   3.570 ++++ mpfr-3.0.0-b/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   3.571 +@@ -27,7 +27,7 @@
   3.572 + #define MPFR_VERSION_MAJOR 3
   3.573 + #define MPFR_VERSION_MINOR 0
   3.574 + #define MPFR_VERSION_PATCHLEVEL 0
   3.575 +-#define MPFR_VERSION_STRING "3.0.0-p1"
   3.576 ++#define MPFR_VERSION_STRING "3.0.0-p2"
   3.577 + 
   3.578 + /* Macros dealing with MPFR VERSION */
   3.579 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.580 +diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
   3.581 +--- mpfr-3.0.0-a/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.582 ++++ mpfr-3.0.0-b/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.583 +@@ -960,6 +960,7 @@
   3.584 + red=; grn=; lgn=; blu=; std=
   3.585 + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   3.586 + ACLOCAL = @ACLOCAL@
   3.587 ++ALLOCA = @ALLOCA@
   3.588 + AMTAR = @AMTAR@
   3.589 + AR = @AR@
   3.590 + AS = @AS@
   3.591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.592 +--- mpfr-3.0.0-a/version.c	2010-06-23 11:03:20.000000000 +0000
   3.593 ++++ mpfr-3.0.0-b/version.c	2010-06-25 13:23:13.000000000 +0000
   3.594 +@@ -25,5 +25,5 @@
   3.595 + const char *
   3.596 + mpfr_get_version (void)
   3.597 + {
   3.598 +-  return "3.0.0-p1";
   3.599 ++  return "3.0.0-p2";
   3.600 + }
   3.601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.602 +--- mpfr-3.0.0-a/PATCHES	2010-07-10 00:11:19.000000000 +0000
   3.603 ++++ mpfr-3.0.0-b/PATCHES	2010-07-10 00:12:50.000000000 +0000
   3.604 +@@ -0,0 +1 @@
   3.605 ++gamma_underflow
   3.606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.607 +--- mpfr-3.0.0-a/VERSION	2010-06-25 13:23:13.000000000 +0000
   3.608 ++++ mpfr-3.0.0-b/VERSION	2010-07-10 00:11:53.000000000 +0000
   3.609 +@@ -1 +1 @@
   3.610 +-3.0.0-p2
   3.611 ++3.0.0-p3
   3.612 +diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
   3.613 +--- mpfr-3.0.0-a/gamma.c	2010-06-10 11:00:14.000000000 +0000
   3.614 ++++ mpfr-3.0.0-b/gamma.c	2010-07-10 00:11:46.000000000 +0000
   3.615 +@@ -274,7 +274,7 @@
   3.616 +       /* we want an upper bound for x * [log(2-x)-1].
   3.617 +          since x < 0, we need a lower bound on log(2-x) */
   3.618 +       mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
   3.619 +-      mpfr_log (xp, xp, MPFR_RNDD);
   3.620 ++      mpfr_log2 (xp, xp, MPFR_RNDD);
   3.621 +       mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
   3.622 +       mpfr_mul (xp, xp, x, MPFR_RNDU);
   3.623 + 
   3.624 +@@ -303,8 +303,8 @@
   3.625 +         {
   3.626 +           mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
   3.627 +           mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
   3.628 +-          mpfr_log (tmp, tmp, MPFR_RNDU);
   3.629 +-          mpfr_add (tmp, tmp, xp, MPFR_RNDU);
   3.630 ++          mpfr_log2 (tmp, tmp, MPFR_RNDU);
   3.631 ++          mpfr_add (xp, tmp, xp, MPFR_RNDU);
   3.632 +           underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
   3.633 +         }
   3.634 + 
   3.635 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.636 +--- mpfr-3.0.0-a/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   3.637 ++++ mpfr-3.0.0-b/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   3.638 +@@ -27,7 +27,7 @@
   3.639 + #define MPFR_VERSION_MAJOR 3
   3.640 + #define MPFR_VERSION_MINOR 0
   3.641 + #define MPFR_VERSION_PATCHLEVEL 0
   3.642 +-#define MPFR_VERSION_STRING "3.0.0-p2"
   3.643 ++#define MPFR_VERSION_STRING "3.0.0-p3"
   3.644 + 
   3.645 + /* Macros dealing with MPFR VERSION */
   3.646 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.647 +diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
   3.648 +--- mpfr-3.0.0-a/tests/tgamma.c	2010-06-10 11:00:13.000000000 +0000
   3.649 ++++ mpfr-3.0.0-b/tests/tgamma.c	2010-07-10 00:11:46.000000000 +0000
   3.650 +@@ -461,6 +461,20 @@
   3.651 +   mpfr_clear (x);
   3.652 + }
   3.653 + 
   3.654 ++/* bug found by Stathis, only occurs on 32-bit machines */
   3.655 ++static void
   3.656 ++test20100709 (void)
   3.657 ++{
   3.658 ++  mpfr_t x;
   3.659 ++  int inex;
   3.660 ++
   3.661 ++  mpfr_init2 (x, 100);
   3.662 ++  mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
   3.663 ++  inex = mpfr_gamma (x, x, MPFR_RNDN);
   3.664 ++  MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
   3.665 ++  mpfr_clear (x);
   3.666 ++}
   3.667 ++
   3.668 + int
   3.669 + main (int argc, char *argv[])
   3.670 + {
   3.671 +@@ -471,6 +485,7 @@
   3.672 +   test_generic (2, 100, 2);
   3.673 +   gamma_integer ();
   3.674 +   test20071231 ();
   3.675 ++  test20100709 ();
   3.676 + 
   3.677 +   data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
   3.678 + 
   3.679 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.680 +--- mpfr-3.0.0-a/version.c	2010-06-25 13:23:13.000000000 +0000
   3.681 ++++ mpfr-3.0.0-b/version.c	2010-07-10 00:11:53.000000000 +0000
   3.682 +@@ -25,5 +25,5 @@
   3.683 + const char *
   3.684 + mpfr_get_version (void)
   3.685 + {
   3.686 +-  return "3.0.0-p2";
   3.687 ++  return "3.0.0-p3";
   3.688 + }
   3.689 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.690 +--- mpfr-3.0.0-a/PATCHES	2010-09-07 08:44:01.000000000 +0000
   3.691 ++++ mpfr-3.0.0-b/PATCHES	2010-09-07 08:48:46.000000000 +0000
   3.692 +@@ -0,0 +1 @@
   3.693 ++mpfr_cmp/set_ui/si
   3.694 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.695 +--- mpfr-3.0.0-a/VERSION	2010-07-10 00:11:53.000000000 +0000
   3.696 ++++ mpfr-3.0.0-b/VERSION	2010-09-07 08:46:06.000000000 +0000
   3.697 +@@ -1 +1 @@
   3.698 +-3.0.0-p3
   3.699 ++3.0.0-p4
   3.700 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.701 +--- mpfr-3.0.0-a/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   3.702 ++++ mpfr-3.0.0-b/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   3.703 +@@ -27,7 +27,7 @@
   3.704 + #define MPFR_VERSION_MAJOR 3
   3.705 + #define MPFR_VERSION_MINOR 0
   3.706 + #define MPFR_VERSION_PATCHLEVEL 0
   3.707 +-#define MPFR_VERSION_STRING "3.0.0-p3"
   3.708 ++#define MPFR_VERSION_STRING "3.0.0-p4"
   3.709 + 
   3.710 + /* Macros dealing with MPFR VERSION */
   3.711 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.712 +@@ -798,35 +798,45 @@
   3.713 +      anyway. Checking with other ICC versions is needed. Possibly detect
   3.714 +      whether warnings are produced or not with a configure test.
   3.715 +    + Remove C++ too, since it complains too much. */
   3.716 ++/* Added casts to improve robustness in case of undefined behavior and
   3.717 ++   compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
   3.718 ++   use such extensions, but these macros will be used by 3rd-party code,
   3.719 ++   where such extensions may be required.
   3.720 ++   Moreover casts to unsigned long have been added to avoid warnings in
   3.721 ++   programs that use MPFR and are compiled with -Wconversion; such casts
   3.722 ++   are OK since if X is a constant expression, then (unsigned long) X is
   3.723 ++   also a constant expression, so that the optimizations still work. */
   3.724 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
   3.725 + #if (__GNUC__ >= 2)
   3.726 + #undef mpfr_cmp_ui
   3.727 +-/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
   3.728 +-#define mpfr_cmp_ui(_f,_u)                 \
   3.729 +- (__builtin_constant_p (_u) && (_u) == 0 ? \
   3.730 +-   mpfr_sgn (_f) :                         \
   3.731 +-   mpfr_cmp_ui_2exp ((_f),(_u),0))
   3.732 ++/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
   3.733 ++   But warning! mpfr_sgn is specified as a macro in the API, thus the macro
   3.734 ++   mustn't be used if side effects are possible, like here. */
   3.735 ++#define mpfr_cmp_ui(_f,_u)                                      \
   3.736 ++  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   3.737 ++   (mpfr_sgn) (_f) :                                            \
   3.738 ++   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
   3.739 + #undef mpfr_cmp_si
   3.740 +-#define mpfr_cmp_si(_f,_s)                 \
   3.741 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   3.742 +-   mpfr_cmp_ui ((_f), (_s)) :              \
   3.743 +-   mpfr_cmp_si_2exp ((_f), (_s), 0))
   3.744 ++#define mpfr_cmp_si(_f,_s)                              \
   3.745 ++  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
   3.746 ++   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
   3.747 ++   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
   3.748 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
   3.749 + #undef mpfr_set_ui
   3.750 +-#define mpfr_set_ui(_f,_u,_r)              \
   3.751 +- (__builtin_constant_p (_u) && (_u) == 0 ? \
   3.752 +-   __extension__ ({                        \
   3.753 +-     mpfr_ptr _p = (_f);                   \
   3.754 +-     _p->_mpfr_sign = 1;                   \
   3.755 +-     _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
   3.756 +-     (void) (_r); 0; }) :                  \
   3.757 +-   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
   3.758 ++#define mpfr_set_ui(_f,_u,_r)                                   \
   3.759 ++  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   3.760 ++   __extension__ ({                                             \
   3.761 ++       mpfr_ptr _p = (_f);                                      \
   3.762 ++       _p->_mpfr_sign = 1;                                      \
   3.763 ++       _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
   3.764 ++       (void) (_r); 0; }) :                                     \
   3.765 ++   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
   3.766 + #endif
   3.767 + #undef mpfr_set_si
   3.768 +-#define mpfr_set_si(_f,_s,_r)              \
   3.769 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   3.770 +-   mpfr_set_ui ((_f), (_s), (_r)) :        \
   3.771 +-   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
   3.772 ++#define mpfr_set_si(_f,_s,_r)                                   \
   3.773 ++  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
   3.774 ++   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
   3.775 ++   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
   3.776 + #endif
   3.777 + #endif
   3.778 + 
   3.779 +diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
   3.780 +--- mpfr-3.0.0-a/tests/tcmp_ui.c	2010-06-10 11:00:13.000000000 +0000
   3.781 ++++ mpfr-3.0.0-b/tests/tcmp_ui.c	2010-09-07 08:45:12.000000000 +0000
   3.782 +@@ -88,6 +88,126 @@
   3.783 +   mpfr_clear (x);
   3.784 + }
   3.785 + 
   3.786 ++/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
   3.787 ++   with __builtin_constant_p for GCC, check that side effects are
   3.788 ++   handled correctly. */
   3.789 ++static void
   3.790 ++check_macros (void)
   3.791 ++{
   3.792 ++  mpfr_t x;
   3.793 ++  int c;
   3.794 ++
   3.795 ++  mpfr_init2 (x, 32);
   3.796 ++
   3.797 ++  c = 0;
   3.798 ++  mpfr_set_ui (x, 17, MPFR_RNDN);
   3.799 ++  if (mpfr_cmp_ui (x, 17) != 0)
   3.800 ++    {
   3.801 ++      printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
   3.802 ++      exit (1);
   3.803 ++    }
   3.804 ++  if (mpfr_cmp_ui (x, (c++, 17)) != 0)
   3.805 ++    {
   3.806 ++      printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
   3.807 ++      exit (1);
   3.808 ++    }
   3.809 ++  if (c != 1)
   3.810 ++    {
   3.811 ++      printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
   3.812 ++              "(c = %d instead of 1)\n", c);
   3.813 ++      exit (1);
   3.814 ++    }
   3.815 ++  if (mpfr_cmp_si (x, 17) != 0)
   3.816 ++    {
   3.817 ++      printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
   3.818 ++      exit (1);
   3.819 ++    }
   3.820 ++  if (mpfr_cmp_si (x, (c++, 17)) != 0)
   3.821 ++    {
   3.822 ++      printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
   3.823 ++      exit (1);
   3.824 ++    }
   3.825 ++  if (c != 2)
   3.826 ++    {
   3.827 ++      printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
   3.828 ++              "(c = %d instead of 2)\n", c);
   3.829 ++      exit (1);
   3.830 ++    }
   3.831 ++
   3.832 ++  c = 0;
   3.833 ++  mpfr_set_ui (x, 0, MPFR_RNDN);
   3.834 ++  if (mpfr_cmp_ui (x, 0) != 0)
   3.835 ++    {
   3.836 ++      printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
   3.837 ++      exit (1);
   3.838 ++    }
   3.839 ++  if (mpfr_cmp_ui (x, (c++, 0)) != 0)
   3.840 ++    {
   3.841 ++      printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
   3.842 ++      exit (1);
   3.843 ++    }
   3.844 ++  if (c != 1)
   3.845 ++    {
   3.846 ++      printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
   3.847 ++              "(c = %d instead of 1)\n", c);
   3.848 ++      exit (1);
   3.849 ++    }
   3.850 ++  if (mpfr_cmp_si (x, 0) != 0)
   3.851 ++    {
   3.852 ++      printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
   3.853 ++      exit (1);
   3.854 ++    }
   3.855 ++  if (mpfr_cmp_si (x, (c++, 0)) != 0)
   3.856 ++    {
   3.857 ++      printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
   3.858 ++      exit (1);
   3.859 ++    }
   3.860 ++  if (c != 2)
   3.861 ++    {
   3.862 ++      printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
   3.863 ++              "(c = %d instead of 2)\n", c);
   3.864 ++      exit (1);
   3.865 ++    }
   3.866 ++
   3.867 ++  mpfr_clear (x);
   3.868 ++}
   3.869 ++
   3.870 ++/* Bug in r7114 */
   3.871 ++static void
   3.872 ++test_macros (void)
   3.873 ++{
   3.874 ++  mpfr_t x[3];
   3.875 ++  mpfr_ptr p;
   3.876 ++
   3.877 ++  mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
   3.878 ++  mpfr_set_ui (x[0], 0, MPFR_RNDN);
   3.879 ++  p = x[0];
   3.880 ++  if (mpfr_cmp_ui (p++, 0) != 0)
   3.881 ++    {
   3.882 ++      printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
   3.883 ++      exit (1);
   3.884 ++    }
   3.885 ++  if (p != x[1])
   3.886 ++    {
   3.887 ++      printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
   3.888 ++              (int) (p - x[0]));
   3.889 ++      exit (1);
   3.890 ++    }
   3.891 ++  p = x[0];
   3.892 ++  if (mpfr_cmp_si (p++, 0) != 0)
   3.893 ++    {
   3.894 ++      printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
   3.895 ++      exit (1);
   3.896 ++    }
   3.897 ++  if (p != x[1])
   3.898 ++    {
   3.899 ++      printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
   3.900 ++              (int) (p - x[0]));
   3.901 ++      exit (1);
   3.902 ++    }
   3.903 ++  mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
   3.904 ++}
   3.905 ++
   3.906 + int
   3.907 + main (void)
   3.908 + {
   3.909 +@@ -216,6 +336,8 @@
   3.910 +   mpfr_clear (x);
   3.911 + 
   3.912 +   check_nan ();
   3.913 ++  check_macros ();
   3.914 ++  test_macros ();
   3.915 + 
   3.916 +   tests_end_mpfr ();
   3.917 +   return 0;
   3.918 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.919 +--- mpfr-3.0.0-a/version.c	2010-07-10 00:11:53.000000000 +0000
   3.920 ++++ mpfr-3.0.0-b/version.c	2010-09-07 08:46:06.000000000 +0000
   3.921 +@@ -25,5 +25,5 @@
   3.922 + const char *
   3.923 + mpfr_get_version (void)
   3.924 + {
   3.925 +-  return "3.0.0-p3";
   3.926 ++  return "3.0.0-p4";
   3.927 + }
   3.928 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.929 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 20:28:38.000000000 +0000
   3.930 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:28:38.000000000 +0000
   3.931 +@@ -0,0 +1 @@
   3.932 ++tcan_round
   3.933 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.934 +--- mpfr-3.0.0-a/VERSION	2010-09-07 08:46:06.000000000 +0000
   3.935 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 20:28:38.000000000 +0000
   3.936 +@@ -1 +1 @@
   3.937 +-3.0.0-p4
   3.938 ++3.0.0-p5
   3.939 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.940 +--- mpfr-3.0.0-a/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   3.941 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   3.942 +@@ -27,7 +27,7 @@
   3.943 + #define MPFR_VERSION_MAJOR 3
   3.944 + #define MPFR_VERSION_MINOR 0
   3.945 + #define MPFR_VERSION_PATCHLEVEL 0
   3.946 +-#define MPFR_VERSION_STRING "3.0.0-p4"
   3.947 ++#define MPFR_VERSION_STRING "3.0.0-p5"
   3.948 + 
   3.949 + /* Macros dealing with MPFR VERSION */
   3.950 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.951 +diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
   3.952 +--- mpfr-3.0.0-a/tests/tcan_round.c	2010-06-10 11:00:13.000000000 +0000
   3.953 ++++ mpfr-3.0.0-b/tests/tcan_round.c	2010-10-21 20:28:38.000000000 +0000
   3.954 +@@ -41,7 +41,7 @@
   3.955 +       /* avoid mpn_random which leaks memory */
   3.956 +       for (i = 0; i < n; i++)
   3.957 +         buf[i] = randlimb ();
   3.958 +-      p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   3.959 ++      p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   3.960 +       err = p + randlimb () % GMP_NUMB_BITS;
   3.961 +       r1 = mpfr_round_p (buf, n, err, p);
   3.962 +       r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
   3.963 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.964 +--- mpfr-3.0.0-a/version.c	2010-09-07 08:46:06.000000000 +0000
   3.965 ++++ mpfr-3.0.0-b/version.c	2010-10-21 20:28:38.000000000 +0000
   3.966 +@@ -25,5 +25,5 @@
   3.967 + const char *
   3.968 + mpfr_get_version (void)
   3.969 + {
   3.970 +-  return "3.0.0-p4";
   3.971 ++  return "3.0.0-p5";
   3.972 + }
   3.973 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.974 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 20:59:32.000000000 +0000
   3.975 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:59:32.000000000 +0000
   3.976 +@@ -0,0 +1 @@
   3.977 ++mpfr_sub1
   3.978 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.979 +--- mpfr-3.0.0-a/VERSION	2010-10-21 20:28:38.000000000 +0000
   3.980 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 20:59:32.000000000 +0000
   3.981 +@@ -1 +1 @@
   3.982 +-3.0.0-p5
   3.983 ++3.0.0-p6
   3.984 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.985 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   3.986 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:59:32.000000000 +0000
   3.987 +@@ -27,7 +27,7 @@
   3.988 + #define MPFR_VERSION_MAJOR 3
   3.989 + #define MPFR_VERSION_MINOR 0
   3.990 + #define MPFR_VERSION_PATCHLEVEL 0
   3.991 +-#define MPFR_VERSION_STRING "3.0.0-p5"
   3.992 ++#define MPFR_VERSION_STRING "3.0.0-p6"
   3.993 + 
   3.994 + /* Macros dealing with MPFR VERSION */
   3.995 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.996 +diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
   3.997 +--- mpfr-3.0.0-a/sub1.c	2010-06-10 11:00:14.000000000 +0000
   3.998 ++++ mpfr-3.0.0-b/sub1.c	2010-10-21 20:59:32.000000000 +0000
   3.999 +@@ -37,7 +37,9 @@
  3.1000 +   mp_size_t cancel2, an, bn, cn, cn0;
  3.1001 +   mp_limb_t *ap, *bp, *cp;
  3.1002 +   mp_limb_t carry, bb, cc, borrow = 0;
  3.1003 +-  int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
  3.1004 ++  int inexact, shift_b, shift_c, add_exp = 0;
  3.1005 ++  int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
  3.1006 ++                      negative if low(b) < low(c), positive if low(b)>low(c) */
  3.1007 +   int sh, k;
  3.1008 +   MPFR_TMP_DECL(marker);
  3.1009 + 
  3.1010 +@@ -196,7 +198,8 @@
  3.1011 +     }
  3.1012 + 
  3.1013 + #ifdef DEBUG
  3.1014 +-  printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
  3.1015 ++  printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
  3.1016 ++          mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
  3.1017 +           (unsigned long) diff_exp);
  3.1018 + #endif
  3.1019 + 
  3.1020 +@@ -307,17 +310,18 @@
  3.1021 +     {
  3.1022 +       if (MPFR_LIKELY(sh))
  3.1023 +         {
  3.1024 +-          is_exact = (carry == 0);
  3.1025 +           /* can decide except when carry = 2^(sh-1) [middle]
  3.1026 +              or carry = 0 [truncate, but cannot decide inexact flag] */
  3.1027 +-          down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
  3.1028 +           if (carry > (MPFR_LIMB_ONE << (sh - 1)))
  3.1029 +             goto add_one_ulp;
  3.1030 +-          else if ((0 < carry) && down)
  3.1031 ++          else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
  3.1032 +             {
  3.1033 +               inexact = -1; /* result if smaller than exact value */
  3.1034 +               goto truncate;
  3.1035 +             }
  3.1036 ++          /* now carry = 2^(sh-1), in which case cmp_low=2,
  3.1037 ++             or carry = 0, in which case cmp_low=0 */
  3.1038 ++          cmp_low = (carry == 0) ? 0 : 2;
  3.1039 +         }
  3.1040 +     }
  3.1041 +   else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
  3.1042 +@@ -344,12 +348,32 @@
  3.1043 +   cn -= (long int) an + cancel2;
  3.1044 + 
  3.1045 + #ifdef DEBUG
  3.1046 +-  printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
  3.1047 ++  printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
  3.1048 +           sh, (unsigned long) carry, (long) bn, (long) cn);
  3.1049 + #endif
  3.1050 + 
  3.1051 ++  /* for rounding to nearest, we couldn't conclude up to here in the following
  3.1052 ++     cases:
  3.1053 ++     1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
  3.1054 ++        or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
  3.1055 ++     2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
  3.1056 ++        -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
  3.1057 ++        we can't decide the rounding, in that case cmp_low=2:
  3.1058 ++        either we truncate and flag=-1, or we add one ulp and flag=1
  3.1059 ++     3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
  3.1060 ++        truncate but we can't decide the ternary value, here cmp_low=0:
  3.1061 ++        -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
  3.1062 ++        we always truncate and inexact can be any of -1,0,1
  3.1063 ++  */
  3.1064 ++
  3.1065 ++  /* note: here cn might exceed cn0, in which case we consider a zero limb */
  3.1066 +   for (k = 0; (bn > 0) || (cn > 0); k = 1)
  3.1067 +     {
  3.1068 ++      /* if cmp_low < 0, we know low(b) - low(c) < 0
  3.1069 ++         if cmp_low > 0, we know low(b) - low(c) > 0
  3.1070 ++            (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
  3.1071 ++         if cmp_low = 0, so far low(b) - low(c) = 0 */
  3.1072 ++
  3.1073 +       /* get next limbs */
  3.1074 +       bb = (bn > 0) ? bp[--bn] : 0;
  3.1075 +       if ((cn > 0) && (cn-- <= cn0))
  3.1076 +@@ -357,76 +381,115 @@
  3.1077 +       else
  3.1078 +         cc = 0;
  3.1079 + 
  3.1080 +-      /* down is set when low(b) < low(c) */
  3.1081 +-      if (down == 0)
  3.1082 +-        down = (bb < cc);
  3.1083 ++      /* cmp_low compares low(b) and low(c) */
  3.1084 ++      if (cmp_low == 0) /* case 1 or 3 */
  3.1085 ++        cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
  3.1086 ++
  3.1087 ++      /* Case 1 for k=0 splits into 7 subcases:
  3.1088 ++         1a: bb > cc + half
  3.1089 ++         1b: bb = cc + half
  3.1090 ++         1c: 0 < bb - cc < half
  3.1091 ++         1d: bb = cc
  3.1092 ++         1e: -half < bb - cc < 0
  3.1093 ++         1f: bb - cc = -half
  3.1094 ++         1g: bb - cc < -half
  3.1095 ++
  3.1096 ++         Case 2 splits into 3 subcases:
  3.1097 ++         2a: bb > cc
  3.1098 ++         2b: bb = cc
  3.1099 ++         2c: bb < cc
  3.1100 ++
  3.1101 ++         Case 3 splits into 3 subcases:
  3.1102 ++         3a: bb > cc
  3.1103 ++         3b: bb = cc
  3.1104 ++         3c: bb < cc
  3.1105 ++      */
  3.1106 + 
  3.1107 +       /* the case rounding to nearest with sh=0 is special since one couldn't
  3.1108 +          subtract above 1/2 ulp in the trailing limb of the result */
  3.1109 +-      if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
  3.1110 ++      if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
  3.1111 +         {
  3.1112 +           mp_limb_t half = MPFR_LIMB_HIGHBIT;
  3.1113 + 
  3.1114 +-          is_exact = (bb == cc);
  3.1115 +-
  3.1116 +           /* add one ulp if bb > cc + half
  3.1117 +              truncate if cc - half < bb < cc + half
  3.1118 +              sub one ulp if bb < cc - half
  3.1119 +           */
  3.1120 + 
  3.1121 +-          if (down)
  3.1122 ++          if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
  3.1123 ++                              cases 1e, 1f and 1g */
  3.1124 +             {
  3.1125 +               if (cc >= half)
  3.1126 +                 cc -= half;
  3.1127 +-              else
  3.1128 ++              else /* since bb < cc < half, bb+half < 2*half */
  3.1129 +                 bb += half;
  3.1130 ++              /* now we have bb < cc + half:
  3.1131 ++                 we have to subtract one ulp if bb < cc,
  3.1132 ++                 and truncate if bb > cc */
  3.1133 +             }
  3.1134 +-          else /* bb >= cc */
  3.1135 ++          else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
  3.1136 +             {
  3.1137 +               if (cc < half)
  3.1138 +                 cc += half;
  3.1139 +-              else
  3.1140 ++              else /* since bb >= cc >= half, bb - half >= 0 */
  3.1141 +                 bb -= half;
  3.1142 ++              /* now we have bb > cc - half: we have to add one ulp if bb > cc,
  3.1143 ++                 and truncate if bb < cc */
  3.1144 ++              if (cmp_low > 0)
  3.1145 ++                cmp_low = 2;
  3.1146 +             }
  3.1147 +         }
  3.1148 + 
  3.1149 + #ifdef DEBUG
  3.1150 +-      printf ("    bb=%lu cc=%lu down=%d is_exact=%d\n",
  3.1151 +-              (unsigned long) bb, (unsigned long) cc, down, is_exact);
  3.1152 ++      printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
  3.1153 ++              (unsigned long) bb, (unsigned long) cc, cmp_low);
  3.1154 + #endif
  3.1155 +-      if (bb < cc)
  3.1156 ++      if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
  3.1157 ++                          one ulp */
  3.1158 +         {
  3.1159 +           if (rnd_mode == MPFR_RNDZ)
  3.1160 +-            goto sub_one_ulp;
  3.1161 ++            goto sub_one_ulp; /* set inexact=-1 */
  3.1162 +           else if (rnd_mode != MPFR_RNDN) /* round away */
  3.1163 +             {
  3.1164 +               inexact = 1;
  3.1165 +               goto truncate;
  3.1166 +             }
  3.1167 +-          else /* round to nearest: special case here since for sh=k=0
  3.1168 +-                  bb = bb0 - MPFR_LIMB_HIGHBIT */
  3.1169 ++          else /* round to nearest */
  3.1170 +             {
  3.1171 +-              if (is_exact && sh == 0)
  3.1172 +-                {
  3.1173 +-                  /* For k=0 we can't decide exactness since it may depend
  3.1174 +-                     from low order bits.
  3.1175 +-                     For k=1, the first low limbs matched: low(b)-low(c)<0. */
  3.1176 +-                  if (k)
  3.1177 +-                    {
  3.1178 +-                      inexact = 1;
  3.1179 +-                      goto truncate;
  3.1180 +-                    }
  3.1181 +-                }
  3.1182 +-              else if (down && sh == 0)
  3.1183 +-                goto sub_one_ulp;
  3.1184 +-              else
  3.1185 +-                {
  3.1186 +-                  inexact = (is_exact) ? 1 : -1;
  3.1187 ++              /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
  3.1188 ++                 whatever the value of sh.
  3.1189 ++                 If sh>0, then cmp_low < 0 implies that the initial neglected
  3.1190 ++                 sh bits were 0 (otherwise cmp_low=2 initially), thus the
  3.1191 ++                 weight of the new bits is less than 0.5 ulp too.
  3.1192 ++                 If k > 0 (and sh=0) this means that either the first neglected
  3.1193 ++                 limbs bb and cc were equal (thus cmp_low was 0 for k=0),
  3.1194 ++                 or we had bb - cc = -0.5 ulp or 0.5 ulp.
  3.1195 ++                 The last case is not possible here since we would have
  3.1196 ++                 cmp_low > 0 which is sticky.
  3.1197 ++                 In the first case (where we have cmp_low = -1), we truncate,
  3.1198 ++                 whereas in the 2nd case we have cmp_low = -2 and we subtract
  3.1199 ++                 one ulp.
  3.1200 ++              */
  3.1201 ++              if (bb > cc || sh > 0 || cmp_low == -1)
  3.1202 ++                {  /* -0.5 ulp < low(b)-low(c) < 0,
  3.1203 ++                      bb > cc corresponds to cases 1e and 1f1
  3.1204 ++                      sh > 0 corresponds to cases 3c and 3b3
  3.1205 ++                      cmp_low = -1 corresponds to case 1d3 (also 3b3) */
  3.1206 ++                  inexact = 1;
  3.1207 +                   goto truncate;
  3.1208 +                 }
  3.1209 ++              else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
  3.1210 ++                                   this corresponds to cases 1g and 1f3 */
  3.1211 ++                goto sub_one_ulp;
  3.1212 ++              /* the only case where we can't conclude is sh=0 and bb=cc,
  3.1213 ++                 i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
  3.1214 ++                 we don't know if we must truncate or subtract one ulp.
  3.1215 ++                 Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
  3.1216 ++                 now, since low(b) - low(c) > 1/2^sh */
  3.1217 +             }
  3.1218 +         }
  3.1219 +-      else if (bb > cc)
  3.1220 ++      else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
  3.1221 ++                               add one ulp */
  3.1222 +         {
  3.1223 +           if (rnd_mode == MPFR_RNDZ)
  3.1224 +             {
  3.1225 +@@ -437,34 +500,70 @@
  3.1226 +             goto add_one_ulp;
  3.1227 +           else /* round to nearest */
  3.1228 +             {
  3.1229 +-              if (is_exact)
  3.1230 ++              if (bb > cc)
  3.1231 +                 {
  3.1232 +-                  inexact = -1;
  3.1233 +-                  goto truncate;
  3.1234 ++                  /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
  3.1235 ++                     and similarly when cmp_low=2 */
  3.1236 ++                  if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
  3.1237 ++                    goto add_one_ulp;
  3.1238 ++                  /* sh > 0 and cmp_low > 0: this implies that the sh initial
  3.1239 ++                     neglected bits were 0, and the remaining low(b)-low(c)>0,
  3.1240 ++                     but its weight is less than 0.5 ulp */
  3.1241 ++                  else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
  3.1242 ++                          cases 3a, 1d1 and 3b1 */
  3.1243 ++                    {
  3.1244 ++                      inexact = -1;
  3.1245 ++                      goto truncate;
  3.1246 ++                    }
  3.1247 +                 }
  3.1248 +-              else if (down)
  3.1249 ++              else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
  3.1250 ++                                   1b3, 2b3 and 2c */
  3.1251 +                 {
  3.1252 +-                  inexact = 1;
  3.1253 ++                  inexact = -1;
  3.1254 +                   goto truncate;
  3.1255 +                 }
  3.1256 +-              else
  3.1257 +-                goto add_one_ulp;
  3.1258 ++              /* the only case where we can't conclude is bb=cc, i.e.,
  3.1259 ++                 low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
  3.1260 ++                 if we must truncate or add one ulp. */
  3.1261 +             }
  3.1262 +         }
  3.1263 ++      /* after k=0, we cannot conclude in the following cases, we split them
  3.1264 ++         according to the values of bb and cc for k=1:
  3.1265 ++         1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
  3.1266 ++             1b1. bb > cc: add one ulp, inex = 1
  3.1267 ++             1b2: bb = cc: cannot conclude
  3.1268 ++             1b3: bb < cc: truncate, inex = -1
  3.1269 ++         1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
  3.1270 ++             1d1: bb > cc: truncate, inex = -1
  3.1271 ++             1d2: bb = cc: cannot conclude
  3.1272 ++             1d3: bb < cc: truncate, inex = +1
  3.1273 ++         1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
  3.1274 ++             1f1: bb > cc: truncate, inex = +1
  3.1275 ++             1f2: bb = cc: cannot conclude
  3.1276 ++             1f3: bb < cc: sub one ulp, inex = -1
  3.1277 ++         2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
  3.1278 ++             2b1. bb > cc: add one ulp, inex = 1
  3.1279 ++             2b2: bb = cc: cannot conclude
  3.1280 ++             2b3: bb < cc: truncate, inex = -1
  3.1281 ++         3b. sh > 0 and cmp_low = 0 [around 0]
  3.1282 ++             3b1. bb > cc: truncate, inex = -1
  3.1283 ++             3b2: bb = cc: cannot conclude
  3.1284 ++             3b3: bb < cc: truncate, inex = +1
  3.1285 ++      */
  3.1286 +     }
  3.1287 + 
  3.1288 +-  if ((rnd_mode == MPFR_RNDN) && !is_exact)
  3.1289 ++  if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
  3.1290 +     {
  3.1291 +       /* even rounding rule */
  3.1292 +       if ((ap[0] >> sh) & 1)
  3.1293 +         {
  3.1294 +-          if (down)
  3.1295 ++          if (cmp_low < 0)
  3.1296 +             goto sub_one_ulp;
  3.1297 +           else
  3.1298 +             goto add_one_ulp;
  3.1299 +         }
  3.1300 +       else
  3.1301 +-        inexact = (down) ? 1 : -1;
  3.1302 ++        inexact = (cmp_low > 0) ? -1 : 1;
  3.1303 +     }
  3.1304 +   else
  3.1305 +     inexact = 0;
  3.1306 +diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
  3.1307 +--- mpfr-3.0.0-a/tests/tfma.c	2010-06-10 11:00:13.000000000 +0000
  3.1308 ++++ mpfr-3.0.0-b/tests/tfma.c	2010-10-21 20:59:32.000000000 +0000
  3.1309 +@@ -337,6 +337,94 @@
  3.1310 +   mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
  3.1311 + }
  3.1312 + 
  3.1313 ++static void
  3.1314 ++bug20101018 (void)
  3.1315 ++{
  3.1316 ++  mpfr_t x, y, z, t, u;
  3.1317 ++  int i;
  3.1318 ++
  3.1319 ++  mpfr_init2 (x, 64);
  3.1320 ++  mpfr_init2 (y, 64);
  3.1321 ++  mpfr_init2 (z, 64);
  3.1322 ++  mpfr_init2 (t, 64);
  3.1323 ++  mpfr_init2 (u, 64);
  3.1324 ++
  3.1325 ++  mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
  3.1326 ++  mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
  3.1327 ++  mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
  3.1328 ++  mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
  3.1329 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  3.1330 ++  if (mpfr_cmp (u, t) != 0)
  3.1331 ++    {
  3.1332 ++      printf ("Wrong result in bug20101018 (a)\n");
  3.1333 ++      printf ("Expected ");
  3.1334 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  3.1335 ++      printf ("\nGot      ");
  3.1336 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  3.1337 ++      printf ("\n");
  3.1338 ++      exit (1);
  3.1339 ++    }
  3.1340 ++  if (i <= 0)
  3.1341 ++    {
  3.1342 ++      printf ("Wrong ternary value in bug20101018 (a)\n");
  3.1343 ++      printf ("Expected > 0\n");
  3.1344 ++      printf ("Got      %d\n", i);
  3.1345 ++      exit (1);
  3.1346 ++    }
  3.1347 ++
  3.1348 ++  mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
  3.1349 ++  mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
  3.1350 ++  mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
  3.1351 ++  mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
  3.1352 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  3.1353 ++  if (mpfr_cmp (u, t) != 0)
  3.1354 ++    {
  3.1355 ++      printf ("Wrong result in bug20101018 (b)\n");
  3.1356 ++      printf ("Expected ");
  3.1357 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  3.1358 ++      printf ("\nGot      ");
  3.1359 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  3.1360 ++      printf ("\n");
  3.1361 ++      exit (1);
  3.1362 ++    }
  3.1363 ++  if (i <= 0)
  3.1364 ++    {
  3.1365 ++      printf ("Wrong ternary value in bug20101018 (b)\n");
  3.1366 ++      printf ("Expected > 0\n");
  3.1367 ++      printf ("Got      %d\n", i);
  3.1368 ++      exit (1);
  3.1369 ++    }
  3.1370 ++
  3.1371 ++  mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
  3.1372 ++  mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
  3.1373 ++  mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
  3.1374 ++  mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
  3.1375 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  3.1376 ++  if (mpfr_cmp (u, t) != 0)
  3.1377 ++    {
  3.1378 ++      printf ("Wrong result in bug20101018 (c)\n");
  3.1379 ++      printf ("Expected ");
  3.1380 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  3.1381 ++      printf ("\nGot      ");
  3.1382 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  3.1383 ++      printf ("\n");
  3.1384 ++      exit (1);
  3.1385 ++    }
  3.1386 ++  if (i <= 0)
  3.1387 ++    {
  3.1388 ++      printf ("Wrong ternary value in bug20101018 (c)\n");
  3.1389 ++      printf ("Expected > 0\n");
  3.1390 ++      printf ("Got      %d\n", i);
  3.1391 ++      exit (1);
  3.1392 ++    }
  3.1393 ++
  3.1394 ++  mpfr_clear (x);
  3.1395 ++  mpfr_clear (y);
  3.1396 ++  mpfr_clear (z);
  3.1397 ++  mpfr_clear (t);
  3.1398 ++  mpfr_clear (u);
  3.1399 ++}
  3.1400 ++
  3.1401 + int
  3.1402 + main (int argc, char *argv[])
  3.1403 + {
  3.1404 +@@ -345,6 +433,8 @@
  3.1405 + 
  3.1406 +   tests_start_mpfr ();
  3.1407 + 
  3.1408 ++  bug20101018 ();
  3.1409 ++
  3.1410 +   mpfr_init (x);
  3.1411 +   mpfr_init (s);
  3.1412 +   mpfr_init (y);
  3.1413 +diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
  3.1414 +--- mpfr-3.0.0-a/tests/tsub.c	2010-06-10 11:00:13.000000000 +0000
  3.1415 ++++ mpfr-3.0.0-b/tests/tsub.c	2010-10-21 20:59:32.000000000 +0000
  3.1416 +@@ -201,6 +201,8 @@
  3.1417 +   if (mpfr_cmp (z, x))
  3.1418 +     {
  3.1419 +       printf ("Error in mpfr_sub (2)\n");
  3.1420 ++      printf ("Expected "); mpfr_print_binary (x); puts ("");
  3.1421 ++      printf ("Got      "); mpfr_print_binary (z); puts ("");
  3.1422 +       exit (1);
  3.1423 +     }
  3.1424 +   mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
  3.1425 +@@ -478,6 +480,156 @@
  3.1426 +   mpfr_clear (u);
  3.1427 + }
  3.1428 + 
  3.1429 ++/* Bug found by Jakub Jelinek
  3.1430 ++ * http://bugzilla.redhat.com/643657
  3.1431 ++ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
  3.1432 ++ * The consequence can be either an assertion failure (i = 2 in the
  3.1433 ++ * testcase below, in debug mode) or an incorrectly rounded value.
  3.1434 ++ */
  3.1435 ++static void
  3.1436 ++bug20101017 (void)
  3.1437 ++{
  3.1438 ++  mpfr_t a, b, c;
  3.1439 ++  int inex;
  3.1440 ++  int i;
  3.1441 ++
  3.1442 ++  mpfr_init2 (a, GMP_NUMB_BITS * 2);
  3.1443 ++  mpfr_init2 (b, GMP_NUMB_BITS);
  3.1444 ++  mpfr_init2 (c, GMP_NUMB_BITS);
  3.1445 ++
  3.1446 ++  /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
  3.1447 ++     with N = GMP_NUMB_BITS and k = 0 or 1.
  3.1448 ++     c = a - b should round to the same value as a. */
  3.1449 ++
  3.1450 ++  for (i = 2; i <= 3; i++)
  3.1451 ++    {
  3.1452 ++      mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
  3.1453 ++      mpfr_add_ui (a, a, 1, MPFR_RNDN);
  3.1454 ++      mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
  3.1455 ++      mpfr_set_ui (b, 1, MPFR_RNDN);
  3.1456 ++      inex = mpfr_sub (c, a, b, MPFR_RNDN);
  3.1457 ++      mpfr_set (b, a, MPFR_RNDN);
  3.1458 ++      if (! mpfr_equal_p (c, b))
  3.1459 ++        {
  3.1460 ++          printf ("Error in bug20101017 for i = %d.\n", i);
  3.1461 ++          printf ("Expected ");
  3.1462 ++          mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
  3.1463 ++          putchar ('\n');
  3.1464 ++          printf ("Got      ");
  3.1465 ++          mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
  3.1466 ++          putchar ('\n');
  3.1467 ++          exit (1);
  3.1468 ++        }
  3.1469 ++      if (inex >= 0)
  3.1470 ++        {
  3.1471 ++          printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
  3.1472 ++          printf ("Expected negative, got %d.\n", inex);
  3.1473 ++          exit (1);
  3.1474 ++        }
  3.1475 ++    }
  3.1476 ++
  3.1477 ++  mpfr_set_prec (a, 64);
  3.1478 ++  mpfr_set_prec (b, 129);
  3.1479 ++  mpfr_set_prec (c, 2);
  3.1480 ++  mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
  3.1481 ++  mpfr_set_str_binary (c, "0.10E1");
  3.1482 ++  inex = mpfr_sub (a, b, c, MPFR_RNDN);
  3.1483 ++  if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
  3.1484 ++    {
  3.1485 ++      printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
  3.1486 ++      printf ("Expected result 2^64 with inex < 0\n");
  3.1487 ++      printf ("Got "); mpfr_print_binary (a);
  3.1488 ++      printf (" with inex=%d\n", inex);
  3.1489 ++      exit (1);
  3.1490 ++    }
  3.1491 ++
  3.1492 ++  mpfr_clears (a, b, c, (mpfr_ptr) 0);
  3.1493 ++}
  3.1494 ++
  3.1495 ++/* hard test of rounding */
  3.1496 ++static void
  3.1497 ++check_rounding (void)
  3.1498 ++{
  3.1499 ++  mpfr_t a, b, c, res;
  3.1500 ++  mpfr_prec_t p;
  3.1501 ++  long k, l;
  3.1502 ++  int i;
  3.1503 ++
  3.1504 ++#define MAXKL (2 * GMP_NUMB_BITS)
  3.1505 ++  for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
  3.1506 ++    {
  3.1507 ++      mpfr_init2 (a, p);
  3.1508 ++      mpfr_init2 (res, p);
  3.1509 ++      mpfr_init2 (b, p + 1 + MAXKL);
  3.1510 ++      mpfr_init2 (c, MPFR_PREC_MIN);
  3.1511 ++
  3.1512 ++      /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
  3.1513 ++      for (k = 0; k <= MAXKL; k++)
  3.1514 ++        for (l = 0; l <= MAXKL; l++)
  3.1515 ++          {
  3.1516 ++            mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
  3.1517 ++            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  3.1518 ++            mpfr_mul_2ui (b, b, k, MPFR_RNDN);
  3.1519 ++            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  3.1520 ++            mpfr_div_2ui (b, b, k, MPFR_RNDN);
  3.1521 ++            mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
  3.1522 ++            i = mpfr_sub (a, b, c, MPFR_RNDN);
  3.1523 ++            /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
  3.1524 ++               2^p for l <= k, and 2^p+2 for l < k */
  3.1525 ++            if (l <= k)
  3.1526 ++              {
  3.1527 ++                if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
  3.1528 ++                  {
  3.1529 ++                    printf ("Wrong result in check_rounding\n");
  3.1530 ++                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  3.1531 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  3.1532 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  3.1533 ++                    printf ("Expected 2^%lu\n", p);
  3.1534 ++                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  3.1535 ++                    exit (1);
  3.1536 ++                  }
  3.1537 ++                if (i >= 0)
  3.1538 ++                  {
  3.1539 ++                    printf ("Wrong ternary value in check_rounding\n");
  3.1540 ++                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  3.1541 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  3.1542 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  3.1543 ++                    printf ("a="); mpfr_print_binary (a); puts ("");
  3.1544 ++                    printf ("Expected < 0, got %d\n", i);
  3.1545 ++                    exit (1);
  3.1546 ++                  }
  3.1547 ++              }
  3.1548 ++            else /* l < k */
  3.1549 ++              {
  3.1550 ++                mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
  3.1551 ++                mpfr_add_ui (res, res, 2, MPFR_RNDN);
  3.1552 ++                if (mpfr_cmp (a, res) != 0)
  3.1553 ++                  {
  3.1554 ++                    printf ("Wrong result in check_rounding\n");
  3.1555 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  3.1556 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  3.1557 ++                    printf ("Expected "); mpfr_print_binary (res); puts ("");
  3.1558 ++                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  3.1559 ++                    exit (1);
  3.1560 ++                  }
  3.1561 ++                if (i <= 0)
  3.1562 ++                  {
  3.1563 ++                    printf ("Wrong ternary value in check_rounding\n");
  3.1564 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  3.1565 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  3.1566 ++                    printf ("Expected > 0, got %d\n", i);
  3.1567 ++                    exit (1);
  3.1568 ++                  }
  3.1569 ++              }
  3.1570 ++          }
  3.1571 ++
  3.1572 ++      mpfr_clear (a);
  3.1573 ++      mpfr_clear (res);
  3.1574 ++      mpfr_clear (b);
  3.1575 ++      mpfr_clear (c);
  3.1576 ++    }
  3.1577 ++}
  3.1578 ++
  3.1579 + #define TEST_FUNCTION test_sub
  3.1580 + #define TWO_ARGS
  3.1581 + #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
  3.1582 +@@ -491,6 +643,8 @@
  3.1583 + 
  3.1584 +   tests_start_mpfr ();
  3.1585 + 
  3.1586 ++  bug20101017 ();
  3.1587 ++  check_rounding ();
  3.1588 +   check_diverse ();
  3.1589 +   check_inexact ();
  3.1590 +   bug_ddefour ();
  3.1591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  3.1592 +--- mpfr-3.0.0-a/version.c	2010-10-21 20:28:38.000000000 +0000
  3.1593 ++++ mpfr-3.0.0-b/version.c	2010-10-21 20:59:32.000000000 +0000
  3.1594 +@@ -25,5 +25,5 @@
  3.1595 + const char *
  3.1596 + mpfr_get_version (void)
  3.1597 + {
  3.1598 +-  return "3.0.0-p5";
  3.1599 ++  return "3.0.0-p6";
  3.1600 + }
  3.1601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  3.1602 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 21:18:26.000000000 +0000
  3.1603 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 21:18:26.000000000 +0000
  3.1604 +@@ -0,0 +1 @@
  3.1605 ++mpfr_set_ld
  3.1606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  3.1607 +--- mpfr-3.0.0-a/VERSION	2010-10-21 20:59:32.000000000 +0000
  3.1608 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 21:18:26.000000000 +0000
  3.1609 +@@ -1 +1 @@
  3.1610 +-3.0.0-p6
  3.1611 ++3.0.0-p7
  3.1612 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  3.1613 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:59:32.000000000 +0000
  3.1614 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  3.1615 +@@ -27,7 +27,7 @@
  3.1616 + #define MPFR_VERSION_MAJOR 3
  3.1617 + #define MPFR_VERSION_MINOR 0
  3.1618 + #define MPFR_VERSION_PATCHLEVEL 0
  3.1619 +-#define MPFR_VERSION_STRING "3.0.0-p6"
  3.1620 ++#define MPFR_VERSION_STRING "3.0.0-p7"
  3.1621 + 
  3.1622 + /* Macros dealing with MPFR VERSION */
  3.1623 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  3.1624 +diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
  3.1625 +--- mpfr-3.0.0-a/set_ld.c	2010-06-10 11:00:14.000000000 +0000
  3.1626 ++++ mpfr-3.0.0-b/set_ld.c	2010-10-21 21:18:26.000000000 +0000
  3.1627 +@@ -102,21 +102,25 @@
  3.1628 +             {
  3.1629 +               x /= div13; /* exact */
  3.1630 +               shift_exp += 8192;
  3.1631 ++              mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
  3.1632 +             }
  3.1633 +           if (ABS (x) >= div12)
  3.1634 +             {
  3.1635 +               x /= div12; /* exact */
  3.1636 +               shift_exp += 4096;
  3.1637 ++              mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
  3.1638 +             }
  3.1639 +           if (ABS (x) >= div11)
  3.1640 +             {
  3.1641 +               x /= div11; /* exact */
  3.1642 +               shift_exp += 2048;
  3.1643 ++              mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
  3.1644 +             }
  3.1645 +           if (ABS (x) >= div10)
  3.1646 +             {
  3.1647 +               x /= div10; /* exact */
  3.1648 +               shift_exp += 1024;
  3.1649 ++              mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
  3.1650 +             }
  3.1651 +           /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
  3.1652 +              therefore we have one extra exponent reduction step */
  3.1653 +@@ -124,9 +128,10 @@
  3.1654 +             {
  3.1655 +               x /= div9; /* exact */
  3.1656 +               shift_exp += 512;
  3.1657 ++              mpfr_div_2si (t, t, 512, MPFR_RNDZ);
  3.1658 +             }
  3.1659 +         } /* Check overflow of double */
  3.1660 +-      else
  3.1661 ++      else /* no overflow on double */
  3.1662 +         {
  3.1663 +           long double div9, div10, div11;
  3.1664 + 
  3.1665 +@@ -149,29 +154,34 @@
  3.1666 +                 {
  3.1667 +                   x /= div13; /* exact */
  3.1668 +                   shift_exp -= 8192;
  3.1669 ++                  mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
  3.1670 +                 }
  3.1671 +               if (ABS (x) <= div12)
  3.1672 +                 {
  3.1673 +                   x /= div12; /* exact */
  3.1674 +                   shift_exp -= 4096;
  3.1675 ++                  mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
  3.1676 +                 }
  3.1677 +               if (ABS (x) <= div11)
  3.1678 +                 {
  3.1679 +                   x /= div11; /* exact */
  3.1680 +                   shift_exp -= 2048;
  3.1681 ++                  mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
  3.1682 +                 }
  3.1683 +               if (ABS (x) <= div10)
  3.1684 +                 {
  3.1685 +                   x /= div10; /* exact */
  3.1686 +                   shift_exp -= 1024;
  3.1687 ++                  mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
  3.1688 +                 }
  3.1689 +               if (ABS(x) <= div9)
  3.1690 +                 {
  3.1691 +                   x /= div9;  /* exact */
  3.1692 +                   shift_exp -= 512;
  3.1693 ++                  mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
  3.1694 +                 }
  3.1695 +             }
  3.1696 +-          else
  3.1697 ++          else /* no underflow */
  3.1698 +             {
  3.1699 +               inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
  3.1700 +               MPFR_ASSERTD (inexact == 0);
  3.1701 +diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
  3.1702 +--- mpfr-3.0.0-a/tests/tset_ld.c	2010-06-10 11:00:13.000000000 +0000
  3.1703 ++++ mpfr-3.0.0-b/tests/tset_ld.c	2010-10-21 21:18:26.000000000 +0000
  3.1704 +@@ -147,12 +147,39 @@
  3.1705 + test_fixed_bugs (void)
  3.1706 + {
  3.1707 +   mpfr_t x;
  3.1708 +-  long double d;
  3.1709 ++  long double l, m;
  3.1710 + 
  3.1711 +   /* bug found by Steve Kargl (2009-03-14) */
  3.1712 +   mpfr_init2 (x, 64);
  3.1713 +   mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
  3.1714 +-  d = mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  3.1715 ++  mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  3.1716 ++
  3.1717 ++  /* bug reported by Jakub Jelinek (2010-10-17)
  3.1718 ++     https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
  3.1719 ++  mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
  3.1720 ++  /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
  3.1721 ++  l = 8.215640181713713164092636634579e-276;
  3.1722 ++  mpfr_set_ld (x, l, MPFR_RNDN);
  3.1723 ++  m = mpfr_get_ld (x, MPFR_RNDN);
  3.1724 ++  if (m != l)
  3.1725 ++    {
  3.1726 ++      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  3.1727 ++      printf ("Got m=%Le instead of l\n", m);
  3.1728 ++      exit (1);
  3.1729 ++    }
  3.1730 ++
  3.1731 ++  /* another similar test which failed with extended double precision and the
  3.1732 ++     generic code for mpfr_set_ld */
  3.1733 ++  /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
  3.1734 ++  l = 4.560596445887084662336528403703e-292;
  3.1735 ++  mpfr_set_ld (x, l, MPFR_RNDN);
  3.1736 ++  m = mpfr_get_ld (x, MPFR_RNDN);
  3.1737 ++  if (m != l)
  3.1738 ++    {
  3.1739 ++      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  3.1740 ++      printf ("Got m=%Le instead of l\n", m);
  3.1741 ++      exit (1);
  3.1742 ++    }
  3.1743 + 
  3.1744 +   mpfr_clear (x);
  3.1745 + }
  3.1746 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  3.1747 +--- mpfr-3.0.0-a/version.c	2010-10-21 20:59:32.000000000 +0000
  3.1748 ++++ mpfr-3.0.0-b/version.c	2010-10-21 21:18:26.000000000 +0000
  3.1749 +@@ -25,5 +25,5 @@
  3.1750 + const char *
  3.1751 + mpfr_get_version (void)
  3.1752 + {
  3.1753 +-  return "3.0.0-p6";
  3.1754 ++  return "3.0.0-p7";
  3.1755 + }
  3.1756 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  3.1757 +--- mpfr-3.0.0-a/PATCHES	2010-11-09 15:15:07.000000000 +0000
  3.1758 ++++ mpfr-3.0.0-b/PATCHES	2010-11-09 15:15:07.000000000 +0000
  3.1759 +@@ -0,0 +1 @@
  3.1760 ++macros
  3.1761 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  3.1762 +--- mpfr-3.0.0-a/VERSION	2010-10-21 21:18:26.000000000 +0000
  3.1763 ++++ mpfr-3.0.0-b/VERSION	2010-11-09 15:15:07.000000000 +0000
  3.1764 +@@ -1 +1 @@
  3.1765 +-3.0.0-p7
  3.1766 ++3.0.0-p8
  3.1767 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  3.1768 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  3.1769 ++++ mpfr-3.0.0-b/mpfr.h	2010-11-09 15:15:07.000000000 +0000
  3.1770 +@@ -27,7 +27,7 @@
  3.1771 + #define MPFR_VERSION_MAJOR 3
  3.1772 + #define MPFR_VERSION_MINOR 0
  3.1773 + #define MPFR_VERSION_PATCHLEVEL 0
  3.1774 +-#define MPFR_VERSION_STRING "3.0.0-p7"
  3.1775 ++#define MPFR_VERSION_STRING "3.0.0-p8"
  3.1776 + 
  3.1777 + /* Macros dealing with MPFR VERSION */
  3.1778 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  3.1779 +@@ -67,6 +67,16 @@
  3.1780 + # define _MPFR_H_HAVE_INTMAX_T 1
  3.1781 + #endif
  3.1782 + 
  3.1783 ++/* Avoid some problems with macro expansion if the user defines macros
  3.1784 ++   with the same name as keywords. By convention, identifiers and macro
  3.1785 ++   names starting with mpfr_ are reserved by MPFR. */
  3.1786 ++typedef void            mpfr_void;
  3.1787 ++typedef int             mpfr_int;
  3.1788 ++typedef unsigned int    mpfr_uint;
  3.1789 ++typedef long            mpfr_long;
  3.1790 ++typedef unsigned long   mpfr_ulong;
  3.1791 ++typedef size_t          mpfr_size_t;
  3.1792 ++
  3.1793 + /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
  3.1794 +    Warning! Changing the contents of this enum should be seen as an
  3.1795 +    interface change since the old and the new types are not compatible
  3.1796 +@@ -136,7 +146,7 @@
  3.1797 + typedef mp_exp_t     mpfr_exp_t;
  3.1798 + 
  3.1799 + /* Definition of the standard exponent limits */
  3.1800 +-#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
  3.1801 ++#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
  3.1802 + #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
  3.1803 + 
  3.1804 + /* Definition of the main structure */
  3.1805 +@@ -725,13 +735,13 @@
  3.1806 +    unexpected results with future compilers and aggressive optimisations.
  3.1807 +    Why not working only with signed types, using INT_MIN and LONG_MIN? */
  3.1808 + #if __GMP_MP_SIZE_T_INT
  3.1809 +-#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
  3.1810 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
  3.1811 +-#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
  3.1812 ++#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
  3.1813 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
  3.1814 ++#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
  3.1815 + #else
  3.1816 +-#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
  3.1817 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
  3.1818 +-#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
  3.1819 ++#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
  3.1820 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
  3.1821 ++#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
  3.1822 + #endif
  3.1823 + 
  3.1824 + /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
  3.1825 +@@ -760,9 +770,9 @@
  3.1826 + #define mpfr_inf_p(_x)      ((_x)->_mpfr_exp == __MPFR_EXP_INF)
  3.1827 + #define mpfr_zero_p(_x)     ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
  3.1828 + #define mpfr_regular_p(_x)  ((_x)->_mpfr_exp >  __MPFR_EXP_INF)
  3.1829 +-#define mpfr_sgn(_x)                                          \
  3.1830 +-  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
  3.1831 +-   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
  3.1832 ++#define mpfr_sgn(_x)                                               \
  3.1833 ++  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                              \
  3.1834 ++   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
  3.1835 +    MPFR_SIGN (_x))
  3.1836 + 
  3.1837 + /* Prevent them from using as lvalues */
  3.1838 +@@ -805,7 +815,19 @@
  3.1839 +    Moreover casts to unsigned long have been added to avoid warnings in
  3.1840 +    programs that use MPFR and are compiled with -Wconversion; such casts
  3.1841 +    are OK since if X is a constant expression, then (unsigned long) X is
  3.1842 +-   also a constant expression, so that the optimizations still work. */
  3.1843 ++   also a constant expression, so that the optimizations still work. The
  3.1844 ++   warnings are probably related to the following two bugs:
  3.1845 ++     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
  3.1846 ++     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
  3.1847 ++   and the casts could be removed once these bugs are fixed.
  3.1848 ++   Casts shouldn't be used on the generic calls (to the ..._2exp functions),
  3.1849 ++   where implicit conversions are performed. Indeed, having at least one
  3.1850 ++   implicit conversion in the macro allows the compiler to emit diagnostics
  3.1851 ++   when normally expected, for instance in the following call:
  3.1852 ++     mpfr_set_ui (x, "foo", MPFR_RNDN);
  3.1853 ++   If this is not possible (for future macros), one of the tricks described
  3.1854 ++   on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
  3.1855 ++   be used. */
  3.1856 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
  3.1857 + #if (__GNUC__ >= 2)
  3.1858 + #undef mpfr_cmp_ui
  3.1859 +@@ -813,45 +835,45 @@
  3.1860 +    But warning! mpfr_sgn is specified as a macro in the API, thus the macro
  3.1861 +    mustn't be used if side effects are possible, like here. */
  3.1862 + #define mpfr_cmp_ui(_f,_u)                                      \
  3.1863 +-  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  3.1864 ++  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  3.1865 +    (mpfr_sgn) (_f) :                                            \
  3.1866 +-   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
  3.1867 ++   mpfr_cmp_ui_2exp ((_f), (_u), 0))
  3.1868 + #undef mpfr_cmp_si
  3.1869 +-#define mpfr_cmp_si(_f,_s)                              \
  3.1870 +-  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
  3.1871 +-   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
  3.1872 +-   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
  3.1873 ++#define mpfr_cmp_si(_f,_s)                                      \
  3.1874 ++  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  3.1875 ++   mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) :          \
  3.1876 ++   mpfr_cmp_si_2exp ((_f), (_s), 0))
  3.1877 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
  3.1878 + #undef mpfr_set_ui
  3.1879 + #define mpfr_set_ui(_f,_u,_r)                                   \
  3.1880 +-  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  3.1881 ++  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  3.1882 +    __extension__ ({                                             \
  3.1883 +        mpfr_ptr _p = (_f);                                      \
  3.1884 +        _p->_mpfr_sign = 1;                                      \
  3.1885 +        _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
  3.1886 +-       (void) (_r); 0; }) :                                     \
  3.1887 +-   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
  3.1888 ++       (mpfr_void) (_r); 0; }) :                                \
  3.1889 ++   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
  3.1890 + #endif
  3.1891 + #undef mpfr_set_si
  3.1892 + #define mpfr_set_si(_f,_s,_r)                                   \
  3.1893 +-  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
  3.1894 +-   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
  3.1895 +-   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
  3.1896 ++  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  3.1897 ++   mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) :    \
  3.1898 ++   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
  3.1899 + #endif
  3.1900 + #endif
  3.1901 + 
  3.1902 + /* Macro version of mpfr_stack interface for fast access */
  3.1903 +-#define mpfr_custom_get_size(p) ((size_t)                            \
  3.1904 ++#define mpfr_custom_get_size(p) ((mpfr_size_t)                          \
  3.1905 +        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
  3.1906 + #define mpfr_custom_init(m,p) do {} while (0)
  3.1907 +-#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
  3.1908 ++#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
  3.1909 + #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
  3.1910 + #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
  3.1911 + #define mpfr_custom_init_set(x,k,e,p,m) do {                   \
  3.1912 +   mpfr_ptr _x = (x);                                           \
  3.1913 +   mpfr_exp_t _e;                                               \
  3.1914 +   mpfr_kind_t _t;                                              \
  3.1915 +-  int _s, _k;                                                  \
  3.1916 ++  mpfr_int _s, _k;                                             \
  3.1917 +   _k = (k);                                                    \
  3.1918 +   if (_k >= 0)  {                                              \
  3.1919 +     _t = (mpfr_kind_t) _k;                                     \
  3.1920 +@@ -868,11 +890,13 @@
  3.1921 +   _x->_mpfr_exp  = _e;                                         \
  3.1922 +   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
  3.1923 +  } while (0)
  3.1924 +-#define mpfr_custom_get_kind(x)                                              \
  3.1925 +-  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
  3.1926 +-  : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
  3.1927 +-  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
  3.1928 +-  : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  3.1929 ++#define mpfr_custom_get_kind(x)                                         \
  3.1930 ++  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ?                                  \
  3.1931 ++    (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x)                        \
  3.1932 ++  : (x)->_mpfr_exp == __MPFR_EXP_INF ?                                  \
  3.1933 ++    (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x)                            \
  3.1934 ++  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND         \
  3.1935 ++  : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  3.1936 + 
  3.1937 + 
  3.1938 + #endif /* MPFR_USE_NO_MACRO */
  3.1939 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  3.1940 +--- mpfr-3.0.0-a/version.c	2010-10-21 21:18:26.000000000 +0000
  3.1941 ++++ mpfr-3.0.0-b/version.c	2010-11-09 15:15:07.000000000 +0000
  3.1942 +@@ -25,5 +25,5 @@
  3.1943 + const char *
  3.1944 + mpfr_get_version (void)
  3.1945 + {
  3.1946 +-  return "3.0.0-p7";
  3.1947 ++  return "3.0.0-p8";
  3.1948 + }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/mpfr/stuff/mpfr-3.0.1.patch	Wed May 11 00:48:49 2011 +0200
     4.3 @@ -0,0 +1,367 @@
     4.4 +diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
     4.5 +--- mpfr-3.0.1-a/PATCHES	2011-04-12 10:50:02.000000000 +0000
     4.6 ++++ mpfr-3.0.1-b/PATCHES	2011-04-12 10:50:02.000000000 +0000
     4.7 +@@ -0,0 +1 @@
     4.8 ++asin_exprange
     4.9 +diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
    4.10 +--- mpfr-3.0.1-a/VERSION	2011-04-04 10:19:18.000000000 +0000
    4.11 ++++ mpfr-3.0.1-b/VERSION	2011-04-12 10:50:02.000000000 +0000
    4.12 +@@ -1 +1 @@
    4.13 +-3.0.1
    4.14 ++3.0.1-p1
    4.15 +diff -Naurd mpfr-3.0.1-a/asin.c mpfr-3.0.1-b/asin.c
    4.16 +--- mpfr-3.0.1-a/asin.c	2011-04-04 10:19:18.000000000 +0000
    4.17 ++++ mpfr-3.0.1-b/asin.c	2011-04-12 10:50:02.000000000 +0000
    4.18 +@@ -63,11 +63,14 @@
    4.19 + 
    4.20 +   compared = mpfr_cmp_ui (xp, 1);
    4.21 + 
    4.22 ++  MPFR_SAVE_EXPO_MARK (expo);
    4.23 ++
    4.24 +   if (MPFR_UNLIKELY (compared >= 0))
    4.25 +     {
    4.26 +       mpfr_clear (xp);
    4.27 +       if (compared > 0)                  /* asin(x) = NaN for |x| > 1 */
    4.28 +         {
    4.29 ++          MPFR_SAVE_EXPO_FREE (expo);
    4.30 +           MPFR_SET_NAN (asin);
    4.31 +           MPFR_RET_NAN;
    4.32 +         }
    4.33 +@@ -80,13 +83,11 @@
    4.34 +               inexact = -mpfr_const_pi (asin, MPFR_INVERT_RND(rnd_mode));
    4.35 +               MPFR_CHANGE_SIGN (asin);
    4.36 +             }
    4.37 +-          mpfr_div_2ui (asin, asin, 1, rnd_mode); /* May underflow */
    4.38 +-          return inexact;
    4.39 ++          mpfr_div_2ui (asin, asin, 1, rnd_mode);
    4.40 +         }
    4.41 +     }
    4.42 +-
    4.43 +-  MPFR_SAVE_EXPO_MARK (expo);
    4.44 +-
    4.45 ++  else
    4.46 ++    {
    4.47 +   /* Compute exponent of 1 - ABS(x) */
    4.48 +   mpfr_ui_sub (xp, 1, xp, MPFR_RNDD);
    4.49 +   MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0);
    4.50 +@@ -115,6 +116,7 @@
    4.51 +   inexact = mpfr_set (asin, xp, rnd_mode);
    4.52 + 
    4.53 +   mpfr_clear (xp);
    4.54 ++    }
    4.55 + 
    4.56 +   MPFR_SAVE_EXPO_FREE (expo);
    4.57 +   return mpfr_check_range (asin, inexact, rnd_mode);
    4.58 +diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
    4.59 +--- mpfr-3.0.1-a/mpfr.h	2011-04-04 10:19:18.000000000 +0000
    4.60 ++++ mpfr-3.0.1-b/mpfr.h	2011-04-12 10:50:02.000000000 +0000
    4.61 +@@ -27,7 +27,7 @@
    4.62 + #define MPFR_VERSION_MAJOR 3
    4.63 + #define MPFR_VERSION_MINOR 0
    4.64 + #define MPFR_VERSION_PATCHLEVEL 1
    4.65 +-#define MPFR_VERSION_STRING "3.0.1"
    4.66 ++#define MPFR_VERSION_STRING "3.0.1-p1"
    4.67 + 
    4.68 + /* Macros dealing with MPFR VERSION */
    4.69 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    4.70 +diff -Naurd mpfr-3.0.1-a/tests/tasin.c mpfr-3.0.1-b/tests/tasin.c
    4.71 +--- mpfr-3.0.1-a/tests/tasin.c	2011-04-04 10:19:17.000000000 +0000
    4.72 ++++ mpfr-3.0.1-b/tests/tasin.c	2011-04-12 10:50:02.000000000 +0000
    4.73 +@@ -219,6 +219,49 @@
    4.74 +   mpfr_clear (y);
    4.75 + }
    4.76 + 
    4.77 ++static void
    4.78 ++reduced_expo_range (void)
    4.79 ++{
    4.80 ++  mpfr_exp_t emin, emax;
    4.81 ++  mpfr_t x, y, ex_y;
    4.82 ++  int inex, ex_inex;
    4.83 ++  unsigned int flags, ex_flags;
    4.84 ++
    4.85 ++  emin = mpfr_get_emin ();
    4.86 ++  emax = mpfr_get_emax ();
    4.87 ++
    4.88 ++  mpfr_inits2 (4, x, y, ex_y, (mpfr_ptr) 0);
    4.89 ++  mpfr_set_str (x, "-0.1e1", 2, MPFR_RNDN);
    4.90 ++
    4.91 ++  mpfr_set_emin (1);
    4.92 ++  mpfr_set_emax (1);
    4.93 ++  mpfr_clear_flags ();
    4.94 ++  inex = mpfr_asin (y, x, MPFR_RNDA);
    4.95 ++  flags = __gmpfr_flags;
    4.96 ++  mpfr_set_emin (emin);
    4.97 ++  mpfr_set_emax (emax);
    4.98 ++
    4.99 ++  mpfr_set_str (ex_y, "-0.1101e1", 2, MPFR_RNDN);
   4.100 ++  ex_inex = -1;
   4.101 ++  ex_flags = MPFR_FLAGS_INEXACT;
   4.102 ++
   4.103 ++  if (SIGN (inex) != ex_inex || flags != ex_flags ||
   4.104 ++      ! mpfr_equal_p (y, ex_y))
   4.105 ++    {
   4.106 ++      printf ("Error in reduced_expo_range\non x = ");
   4.107 ++      mpfr_dump (x);
   4.108 ++      printf ("Expected y = ");
   4.109 ++      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
   4.110 ++      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
   4.111 ++      printf ("Got      y = ");
   4.112 ++      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
   4.113 ++      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
   4.114 ++      exit (1);
   4.115 ++    }
   4.116 ++
   4.117 ++  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
   4.118 ++}
   4.119 ++
   4.120 + int
   4.121 + main (void)
   4.122 + {
   4.123 +@@ -226,6 +269,7 @@
   4.124 + 
   4.125 +   special ();
   4.126 +   special_overflow ();
   4.127 ++  reduced_expo_range ();
   4.128 + 
   4.129 +   test_generic (2, 100, 15);
   4.130 + 
   4.131 +diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   4.132 +--- mpfr-3.0.1-a/version.c	2011-04-04 10:19:18.000000000 +0000
   4.133 ++++ mpfr-3.0.1-b/version.c	2011-04-12 10:50:02.000000000 +0000
   4.134 +@@ -25,5 +25,5 @@
   4.135 + const char *
   4.136 + mpfr_get_version (void)
   4.137 + {
   4.138 +-  return "3.0.1";
   4.139 ++  return "3.0.1-p1";
   4.140 + }
   4.141 +diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   4.142 +--- mpfr-3.0.1-a/PATCHES	2011-05-04 11:18:33.000000000 +0000
   4.143 ++++ mpfr-3.0.1-b/PATCHES	2011-05-04 11:18:33.000000000 +0000
   4.144 +@@ -0,0 +1 @@
   4.145 ++rec_sqrt-carry
   4.146 +diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   4.147 +--- mpfr-3.0.1-a/VERSION	2011-04-12 10:50:02.000000000 +0000
   4.148 ++++ mpfr-3.0.1-b/VERSION	2011-05-04 11:18:33.000000000 +0000
   4.149 +@@ -1 +1 @@
   4.150 +-3.0.1-p1
   4.151 ++3.0.1-p2
   4.152 +diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   4.153 +--- mpfr-3.0.1-a/mpfr.h	2011-04-12 10:50:02.000000000 +0000
   4.154 ++++ mpfr-3.0.1-b/mpfr.h	2011-05-04 11:18:33.000000000 +0000
   4.155 +@@ -27,7 +27,7 @@
   4.156 + #define MPFR_VERSION_MAJOR 3
   4.157 + #define MPFR_VERSION_MINOR 0
   4.158 + #define MPFR_VERSION_PATCHLEVEL 1
   4.159 +-#define MPFR_VERSION_STRING "3.0.1-p1"
   4.160 ++#define MPFR_VERSION_STRING "3.0.1-p2"
   4.161 + 
   4.162 + /* Macros dealing with MPFR VERSION */
   4.163 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.164 +diff -Naurd mpfr-3.0.1-a/rec_sqrt.c mpfr-3.0.1-b/rec_sqrt.c
   4.165 +--- mpfr-3.0.1-a/rec_sqrt.c	2011-04-04 10:19:18.000000000 +0000
   4.166 ++++ mpfr-3.0.1-b/rec_sqrt.c	2011-05-04 11:18:33.000000000 +0000
   4.167 +@@ -375,20 +375,37 @@
   4.168 +       MPFR_ASSERTD(un == ln + 1 || un == ln + 2);
   4.169 +       /* the high un-ln limbs of u will overlap the low part of {x+ln,xn},
   4.170 +          we need to add or subtract the overlapping part {u + ln, un - ln} */
   4.171 ++      /* Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1
   4.172 ++         below (with size = th) mustn't be used. In such a case, the limb
   4.173 ++         (carry) will be 0, so that this is semantically a no-op, but if
   4.174 ++         mpn_add_1 and mpn_sub_1 are used, GMP (currently) still does a
   4.175 ++         non-atomic read/write in a place that is not always allocated,
   4.176 ++         with the possible consequences: a crash if the corresponding
   4.177 ++         address is not mapped, or (rather unlikely) memory corruption
   4.178 ++         if another process/thread writes at the same place; things may
   4.179 ++         be worse with future GMP versions. Hence the tests carry != 0. */
   4.180 +       if (neg == 0)
   4.181 +         {
   4.182 +           if (ln > 0)
   4.183 +             MPN_COPY (x, u, ln);
   4.184 +           cy = mpn_add (x + ln, x + ln, xn, u + ln, un - ln);
   4.185 +           /* add cu at x+un */
   4.186 +-          cy += mpn_add_1 (x + un, x + un, th, cu);
   4.187 ++          if (cu != 0)
   4.188 ++            {
   4.189 ++              MPFR_ASSERTD (th != 0);
   4.190 ++              cy += mpn_add_1 (x + un, x + un, th, cu);
   4.191 ++            }
   4.192 +         }
   4.193 +       else /* negative case */
   4.194 +         {
   4.195 +           /* subtract {u+ln, un-ln} from {x+ln,un} */
   4.196 +           cy = mpn_sub (x + ln, x + ln, xn, u + ln, un - ln);
   4.197 +           /* carry cy is at x+un, like cu */
   4.198 +-          cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
   4.199 ++          if (cy + cu != 0)
   4.200 ++            {
   4.201 ++              MPFR_ASSERTD (th != 0);
   4.202 ++              cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
   4.203 ++            }
   4.204 +           /* cy cannot be zero, since the most significant bit of Xh is 1,
   4.205 +              and the correction is bounded by 2^{-h+3} */
   4.206 +           MPFR_ASSERTD(cy == 0);
   4.207 +diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   4.208 +--- mpfr-3.0.1-a/version.c	2011-04-12 10:50:02.000000000 +0000
   4.209 ++++ mpfr-3.0.1-b/version.c	2011-05-04 11:18:33.000000000 +0000
   4.210 +@@ -25,5 +25,5 @@
   4.211 + const char *
   4.212 + mpfr_get_version (void)
   4.213 + {
   4.214 +-  return "3.0.1-p1";
   4.215 ++  return "3.0.1-p2";
   4.216 + }
   4.217 +diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   4.218 +--- mpfr-3.0.1-a/PATCHES	2011-05-05 00:00:35.000000000 +0000
   4.219 ++++ mpfr-3.0.1-b/PATCHES	2011-05-05 00:00:35.000000000 +0000
   4.220 +@@ -0,0 +1 @@
   4.221 ++atan-expo-range
   4.222 +diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   4.223 +--- mpfr-3.0.1-a/VERSION	2011-05-04 11:18:33.000000000 +0000
   4.224 ++++ mpfr-3.0.1-b/VERSION	2011-05-05 00:00:35.000000000 +0000
   4.225 +@@ -1 +1 @@
   4.226 +-3.0.1-p2
   4.227 ++3.0.1-p3
   4.228 +diff -Naurd mpfr-3.0.1-a/atan.c mpfr-3.0.1-b/atan.c
   4.229 +--- mpfr-3.0.1-a/atan.c	2011-04-04 10:19:18.000000000 +0000
   4.230 ++++ mpfr-3.0.1-b/atan.c	2011-05-05 00:00:35.000000000 +0000
   4.231 +@@ -431,5 +431,5 @@
   4.232 +   MPFR_GROUP_CLEAR (group);
   4.233 + 
   4.234 +   MPFR_SAVE_EXPO_FREE (expo);
   4.235 +-  return mpfr_check_range (arctgt, inexact, rnd_mode);
   4.236 ++  return mpfr_check_range (atan, inexact, rnd_mode);
   4.237 + }
   4.238 +diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   4.239 +--- mpfr-3.0.1-a/mpfr.h	2011-05-04 11:18:33.000000000 +0000
   4.240 ++++ mpfr-3.0.1-b/mpfr.h	2011-05-05 00:00:35.000000000 +0000
   4.241 +@@ -27,7 +27,7 @@
   4.242 + #define MPFR_VERSION_MAJOR 3
   4.243 + #define MPFR_VERSION_MINOR 0
   4.244 + #define MPFR_VERSION_PATCHLEVEL 1
   4.245 +-#define MPFR_VERSION_STRING "3.0.1-p2"
   4.246 ++#define MPFR_VERSION_STRING "3.0.1-p3"
   4.247 + 
   4.248 + /* Macros dealing with MPFR VERSION */
   4.249 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.250 +diff -Naurd mpfr-3.0.1-a/tests/tatan.c mpfr-3.0.1-b/tests/tatan.c
   4.251 +--- mpfr-3.0.1-a/tests/tatan.c	2011-04-04 10:19:17.000000000 +0000
   4.252 ++++ mpfr-3.0.1-b/tests/tatan.c	2011-05-05 00:00:35.000000000 +0000
   4.253 +@@ -535,6 +535,52 @@
   4.254 +   mpfr_clears (a, x, y, (mpfr_ptr) 0);
   4.255 + }
   4.256 + 
   4.257 ++/* http://websympa.loria.fr/wwsympa/arc/mpfr/2011-05/msg00008.html
   4.258 ++ * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
   4.259 ++ */
   4.260 ++static void
   4.261 ++reduced_expo_range (void)
   4.262 ++{
   4.263 ++  mpfr_exp_t emin, emax;
   4.264 ++  mpfr_t x, y, ex_y;
   4.265 ++  int inex, ex_inex;
   4.266 ++  unsigned int flags, ex_flags;
   4.267 ++
   4.268 ++  emin = mpfr_get_emin ();
   4.269 ++  emax = mpfr_get_emax ();
   4.270 ++
   4.271 ++  mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
   4.272 ++  mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);
   4.273 ++
   4.274 ++  mpfr_set_emin (-5);
   4.275 ++  mpfr_set_emax (-5);
   4.276 ++  mpfr_clear_flags ();
   4.277 ++  inex = mpfr_atan (y, x, MPFR_RNDN);
   4.278 ++  flags = __gmpfr_flags;
   4.279 ++  mpfr_set_emin (emin);
   4.280 ++  mpfr_set_emax (emax);
   4.281 ++
   4.282 ++  mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
   4.283 ++  ex_inex = 1;
   4.284 ++  ex_flags = MPFR_FLAGS_INEXACT;
   4.285 ++
   4.286 ++  if (SIGN (inex) != ex_inex || flags != ex_flags ||
   4.287 ++      ! mpfr_equal_p (y, ex_y))
   4.288 ++    {
   4.289 ++      printf ("Error in reduced_expo_range\non x = ");
   4.290 ++      mpfr_dump (x);
   4.291 ++      printf ("Expected y = ");
   4.292 ++      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
   4.293 ++      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
   4.294 ++      printf ("Got      y = ");
   4.295 ++      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
   4.296 ++      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
   4.297 ++      exit (1);
   4.298 ++    }
   4.299 ++
   4.300 ++  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
   4.301 ++}
   4.302 ++
   4.303 + int
   4.304 + main (int argc, char *argv[])
   4.305 + {
   4.306 +@@ -546,6 +592,7 @@
   4.307 +   smallvals_atan2 ();
   4.308 +   atan2_bug_20071003 ();
   4.309 +   atan2_different_prec ();
   4.310 ++  reduced_expo_range ();
   4.311 + 
   4.312 +   test_generic_atan  (2, 200, 17);
   4.313 +   test_generic_atan2 (2, 200, 17);
   4.314 +diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   4.315 +--- mpfr-3.0.1-a/version.c	2011-05-04 11:18:33.000000000 +0000
   4.316 ++++ mpfr-3.0.1-b/version.c	2011-05-05 00:00:35.000000000 +0000
   4.317 +@@ -25,5 +25,5 @@
   4.318 + const char *
   4.319 + mpfr_get_version (void)
   4.320 + {
   4.321 +-  return "3.0.1-p2";
   4.322 ++  return "3.0.1-p3";
   4.323 + }
   4.324 +diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   4.325 +--- mpfr-3.0.1-a/PATCHES	2011-05-09 14:48:24.000000000 +0000
   4.326 ++++ mpfr-3.0.1-b/PATCHES	2011-05-09 14:48:24.000000000 +0000
   4.327 +@@ -0,0 +1 @@
   4.328 ++texp-zero
   4.329 +diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   4.330 +--- mpfr-3.0.1-a/VERSION	2011-05-05 00:00:35.000000000 +0000
   4.331 ++++ mpfr-3.0.1-b/VERSION	2011-05-09 14:48:24.000000000 +0000
   4.332 +@@ -1 +1 @@
   4.333 +-3.0.1-p3
   4.334 ++3.0.1-p4
   4.335 +diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   4.336 +--- mpfr-3.0.1-a/mpfr.h	2011-05-05 00:00:35.000000000 +0000
   4.337 ++++ mpfr-3.0.1-b/mpfr.h	2011-05-09 14:48:24.000000000 +0000
   4.338 +@@ -27,7 +27,7 @@
   4.339 + #define MPFR_VERSION_MAJOR 3
   4.340 + #define MPFR_VERSION_MINOR 0
   4.341 + #define MPFR_VERSION_PATCHLEVEL 1
   4.342 +-#define MPFR_VERSION_STRING "3.0.1-p3"
   4.343 ++#define MPFR_VERSION_STRING "3.0.1-p4"
   4.344 + 
   4.345 + /* Macros dealing with MPFR VERSION */
   4.346 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.347 +diff -Naurd mpfr-3.0.1-a/tests/texp.c mpfr-3.0.1-b/tests/texp.c
   4.348 +--- mpfr-3.0.1-a/tests/texp.c	2011-04-04 10:19:17.000000000 +0000
   4.349 ++++ mpfr-3.0.1-b/tests/texp.c	2011-05-09 14:48:24.000000000 +0000
   4.350 +@@ -170,7 +170,9 @@
   4.351 +       mpfr_set_prec (x, prec);
   4.352 +       mpfr_set_prec (y, prec);
   4.353 +       mpfr_set_prec (z, prec);
   4.354 +-      mpfr_urandomb (x, RANDS);
   4.355 ++      do
   4.356 ++        mpfr_urandomb (x, RANDS);
   4.357 ++      while (MPFR_IS_ZERO (x));  /* 0 is handled by mpfr_exp only */
   4.358 +       rnd = RND_RAND ();
   4.359 +       mpfr_exp_2 (y, x, rnd);
   4.360 +       mpfr_exp_3 (z, x, rnd);
   4.361 +diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   4.362 +--- mpfr-3.0.1-a/version.c	2011-05-05 00:00:35.000000000 +0000
   4.363 ++++ mpfr-3.0.1-b/version.c	2011-05-09 14:48:24.000000000 +0000
   4.364 +@@ -25,5 +25,5 @@
   4.365 + const char *
   4.366 + mpfr_get_version (void)
   4.367 + {
   4.368 +-  return "3.0.1-p3";
   4.369 ++  return "3.0.1-p4";
   4.370 + }