wok-current rev 12265

mpfr add fixes patch
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 12 14:35:51 2012 +0200 (2012-04-12)
parents bdfc74b6f7b0
children 733f7b1b5b2a
files mpfr/stuff/mpfr-3.0.0.patch mpfr/stuff/mpfr-3.0.1.patch mpfr/stuff/mpfr-3.1.0.patch
line diff
     1.1 --- a/mpfr/stuff/mpfr-3.0.0.patch	Thu Apr 12 13:04:07 2012 +0200
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1945 +0,0 @@
     1.4 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
     1.5 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:02:49.000000000 +0000
     1.6 -+++ mpfr-3.0.0-b/PATCHES	2010-06-23 11:03:36.000000000 +0000
     1.7 -@@ -0,0 +1 @@
     1.8 -+mpfr_out_str
     1.9 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
    1.10 ---- mpfr-3.0.0-a/VERSION	2010-06-10 11:00:14.000000000 +0000
    1.11 -+++ mpfr-3.0.0-b/VERSION	2010-06-23 11:03:20.000000000 +0000
    1.12 -@@ -1 +1 @@
    1.13 --3.0.0
    1.14 -+3.0.0-p1
    1.15 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
    1.16 ---- mpfr-3.0.0-a/mpfr.h	2010-06-10 11:00:14.000000000 +0000
    1.17 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-23 11:03:20.000000000 +0000
    1.18 -@@ -27,7 +27,7 @@
    1.19 - #define MPFR_VERSION_MAJOR 3
    1.20 - #define MPFR_VERSION_MINOR 0
    1.21 - #define MPFR_VERSION_PATCHLEVEL 0
    1.22 --#define MPFR_VERSION_STRING "3.0.0"
    1.23 -+#define MPFR_VERSION_STRING "3.0.0-p1"
    1.24 - 
    1.25 - /* Macros dealing with MPFR VERSION */
    1.26 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    1.27 -diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
    1.28 ---- mpfr-3.0.0-a/mpfr.texi	2010-06-10 11:00:14.000000000 +0000
    1.29 -+++ mpfr-3.0.0-b/mpfr.texi	2010-06-23 11:03:12.000000000 +0000
    1.30 -@@ -2050,7 +2050,7 @@
    1.31 - are printed. If @var{base} is greater than 10, @samp{@@} will be used
    1.32 - instead of @samp{e} as exponent delimiter.
    1.33 - 
    1.34 --Return the number of bytes written, or if an error occurred, return 0.
    1.35 -+Return the number of characters written, or if an error occurred, return 0.
    1.36 - @end deftypefun
    1.37 - 
    1.38 - @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
    1.39 -diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
    1.40 ---- mpfr-3.0.0-a/out_str.c	2010-06-10 11:00:14.000000000 +0000
    1.41 -+++ mpfr-3.0.0-b/out_str.c	2010-06-23 11:03:12.000000000 +0000
    1.42 -@@ -22,6 +22,16 @@
    1.43 - 
    1.44 - #include "mpfr-impl.h"
    1.45 - 
    1.46 -+/* Warning! S should not contain "%". */
    1.47 -+#define OUT_STR_RET(S)                          \
    1.48 -+  do                                            \
    1.49 -+    {                                           \
    1.50 -+      int r;                                    \
    1.51 -+      r = fprintf (stream, (S));                \
    1.52 -+      return r < 0 ? 0 : r;                     \
    1.53 -+    }                                           \
    1.54 -+  while (0)
    1.55 -+
    1.56 - size_t
    1.57 - mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
    1.58 -               mpfr_rnd_t rnd_mode)
    1.59 -@@ -29,6 +39,7 @@
    1.60 -   char *s, *s0;
    1.61 -   size_t l;
    1.62 -   mpfr_exp_t e;
    1.63 -+  int err;
    1.64 - 
    1.65 -   MPFR_ASSERTN (base >= 2 && base <= 62);
    1.66 - 
    1.67 -@@ -36,37 +47,16 @@
    1.68 -   if (stream == NULL)
    1.69 -     stream = stdout;
    1.70 - 
    1.71 --  if (MPFR_IS_NAN(op))
    1.72 --    {
    1.73 --      fprintf (stream, "@NaN@");
    1.74 --      return 3;
    1.75 --    }
    1.76 --
    1.77 --  if (MPFR_IS_INF(op))
    1.78 --    {
    1.79 --      if (MPFR_SIGN(op) > 0)
    1.80 --        {
    1.81 --          fprintf (stream, "@Inf@");
    1.82 --          return 3;
    1.83 --        }
    1.84 --      else
    1.85 --        {
    1.86 --          fprintf (stream, "-@Inf@");
    1.87 --          return 4;
    1.88 --        }
    1.89 --    }
    1.90 --
    1.91 --  if (MPFR_IS_ZERO(op))
    1.92 -+  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
    1.93 -     {
    1.94 --      if (MPFR_SIGN(op) > 0)
    1.95 --        {
    1.96 --          fprintf(stream, "0");
    1.97 --          return 1;
    1.98 --        }
    1.99 -+      if (MPFR_IS_NAN (op))
   1.100 -+        OUT_STR_RET ("@NaN@");
   1.101 -+      else if (MPFR_IS_INF (op))
   1.102 -+        OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
   1.103 -       else
   1.104 -         {
   1.105 --          fprintf(stream, "-0");
   1.106 --          return 2;
   1.107 -+          MPFR_ASSERTD (MPFR_IS_ZERO (op));
   1.108 -+          OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
   1.109 -         }
   1.110 -     }
   1.111 - 
   1.112 -@@ -77,21 +67,31 @@
   1.113 - 
   1.114 -   l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
   1.115 -                          - may be incorrect, as only an upper bound? */
   1.116 --  if (*s == '-')
   1.117 --    fputc (*s++, stream);
   1.118 - 
   1.119 --  /* outputs mantissa */
   1.120 --  fputc (*s++, stream); e--; /* leading digit */
   1.121 --  fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
   1.122 --  fputs (s, stream);         /* rest of mantissa */
   1.123 -+  /* outputs possible sign and significand */
   1.124 -+  err = (*s == '-' && fputc (*s++, stream) == EOF)
   1.125 -+    || fputc (*s++, stream) == EOF  /* leading digit */
   1.126 -+    || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
   1.127 -+    || fputs (s, stream) == EOF;     /* trailing significand */
   1.128 -   (*__gmp_free_func) (s0, l);
   1.129 -+  if (MPFR_UNLIKELY (err))
   1.130 -+    return 0;
   1.131 -+
   1.132 -+  e--;  /* due to the leading digit */
   1.133 - 
   1.134 -   /* outputs exponent */
   1.135 -   if (e)
   1.136 -     {
   1.137 -+      int r;
   1.138 -+
   1.139 -       MPFR_ASSERTN(e >= LONG_MIN);
   1.140 -       MPFR_ASSERTN(e <= LONG_MAX);
   1.141 --      l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   1.142 -+
   1.143 -+      r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   1.144 -+      if (MPFR_UNLIKELY (r < 0))
   1.145 -+        return 0;
   1.146 -+
   1.147 -+      l += r;
   1.148 -     }
   1.149 - 
   1.150 -   return l;
   1.151 -diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
   1.152 ---- mpfr-3.0.0-a/tests/tout_str.c	2010-06-10 11:00:13.000000000 +0000
   1.153 -+++ mpfr-3.0.0-b/tests/tout_str.c	2010-06-23 11:03:12.000000000 +0000
   1.154 -@@ -46,22 +46,54 @@
   1.155 - special (void)
   1.156 - {
   1.157 -   mpfr_t x;
   1.158 -+  unsigned int n;
   1.159 - 
   1.160 -   mpfr_init (x);
   1.161 - 
   1.162 -   mpfr_set_nan (x);
   1.163 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.164 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.165 -+  if (n != 5)
   1.166 -+    {
   1.167 -+      printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
   1.168 -+              "characters instead of 5.\n", n);
   1.169 -+      exit (1);
   1.170 -+    }
   1.171 - 
   1.172 -   mpfr_set_inf (x, 1);
   1.173 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.174 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.175 -+  if (n != 5)
   1.176 -+    {
   1.177 -+      printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
   1.178 -+               "characters instead of 5.\n", n);
   1.179 -+      exit (1);
   1.180 -+    }
   1.181 - 
   1.182 -   mpfr_set_inf (x, -1);
   1.183 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.184 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.185 -+  if (n != 6)
   1.186 -+    {
   1.187 -+      printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
   1.188 -+               "characters instead of 6.\n", n);
   1.189 -+      exit (1);
   1.190 -+    }
   1.191 - 
   1.192 -   mpfr_set_ui (x, 0, MPFR_RNDN);
   1.193 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.194 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.195 -+  if (n != 1)
   1.196 -+    {
   1.197 -+      printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
   1.198 -+               "characters instead of 1.\n", n);
   1.199 -+      exit (1);
   1.200 -+    }
   1.201 -+
   1.202 -   mpfr_neg (x, x, MPFR_RNDN);
   1.203 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.204 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   1.205 -+  if (n != 2)
   1.206 -+    {
   1.207 -+      printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
   1.208 -+               "characters instead of 2.\n", n);
   1.209 -+      exit (1);
   1.210 -+    }
   1.211 - 
   1.212 -   mpfr_clear (x);
   1.213 - }
   1.214 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   1.215 ---- mpfr-3.0.0-a/version.c	2010-06-10 11:00:14.000000000 +0000
   1.216 -+++ mpfr-3.0.0-b/version.c	2010-06-23 11:03:20.000000000 +0000
   1.217 -@@ -25,5 +25,5 @@
   1.218 - const char *
   1.219 - mpfr_get_version (void)
   1.220 - {
   1.221 --  return "3.0.0";
   1.222 -+  return "3.0.0-p1";
   1.223 - }
   1.224 -diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
   1.225 ---- mpfr-3.0.0-a/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   1.226 -+++ mpfr-3.0.0-b/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   1.227 -@@ -239,6 +239,7 @@
   1.228 - distuninstallcheck_listfiles = find . -type f -print
   1.229 - distcleancheck_listfiles = find . -type f -print
   1.230 - ACLOCAL = @ACLOCAL@
   1.231 -+ALLOCA = @ALLOCA@
   1.232 - AMTAR = @AMTAR@
   1.233 - AR = @AR@
   1.234 - AS = @AS@
   1.235 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   1.236 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:03:36.000000000 +0000
   1.237 -+++ mpfr-3.0.0-b/PATCHES	2010-06-25 13:23:13.000000000 +0000
   1.238 -@@ -0,0 +1 @@
   1.239 -+alloca
   1.240 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   1.241 ---- mpfr-3.0.0-a/VERSION	2010-06-23 11:03:20.000000000 +0000
   1.242 -+++ mpfr-3.0.0-b/VERSION	2010-06-25 13:23:13.000000000 +0000
   1.243 -@@ -1 +1 @@
   1.244 --3.0.0-p1
   1.245 -+3.0.0-p2
   1.246 -diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
   1.247 ---- mpfr-3.0.0-a/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   1.248 -+++ mpfr-3.0.0-b/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   1.249 -@@ -59,6 +59,9 @@
   1.250 - dnl sys/fpu.h - MIPS specific
   1.251 - AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
   1.252 - 
   1.253 -+dnl Check how to get `alloca'
   1.254 -+AC_FUNC_ALLOCA
   1.255 -+
   1.256 - dnl SIZE_MAX macro
   1.257 - gl_SIZE_MAX
   1.258 - 
   1.259 -diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
   1.260 ---- mpfr-3.0.0-a/configure	2010-06-10 11:00:51.000000000 +0000
   1.261 -+++ mpfr-3.0.0-b/configure	2010-06-25 13:23:05.000000000 +0000
   1.262 -@@ -783,6 +783,7 @@
   1.263 - OBJDUMP
   1.264 - DLLTOOL
   1.265 - AS
   1.266 -+ALLOCA
   1.267 - MPFR_LIBM
   1.268 - ANSI2KNR
   1.269 - U
   1.270 -@@ -5622,6 +5623,197 @@
   1.271 - done
   1.272 - 
   1.273 - 
   1.274 -+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
   1.275 -+# for constant arguments.  Useless!
   1.276 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
   1.277 -+$as_echo_n "checking for working alloca.h... " >&6; }
   1.278 -+if test "${ac_cv_working_alloca_h+set}" = set; then :
   1.279 -+  $as_echo_n "(cached) " >&6
   1.280 -+else
   1.281 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   1.282 -+/* end confdefs.h.  */
   1.283 -+#include <alloca.h>
   1.284 -+int
   1.285 -+main ()
   1.286 -+{
   1.287 -+char *p = (char *) alloca (2 * sizeof (int));
   1.288 -+			  if (p) return 0;
   1.289 -+  ;
   1.290 -+  return 0;
   1.291 -+}
   1.292 -+_ACEOF
   1.293 -+if ac_fn_c_try_link "$LINENO"; then :
   1.294 -+  ac_cv_working_alloca_h=yes
   1.295 -+else
   1.296 -+  ac_cv_working_alloca_h=no
   1.297 -+fi
   1.298 -+rm -f core conftest.err conftest.$ac_objext \
   1.299 -+    conftest$ac_exeext conftest.$ac_ext
   1.300 -+fi
   1.301 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
   1.302 -+$as_echo "$ac_cv_working_alloca_h" >&6; }
   1.303 -+if test $ac_cv_working_alloca_h = yes; then
   1.304 -+
   1.305 -+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
   1.306 -+
   1.307 -+fi
   1.308 -+
   1.309 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
   1.310 -+$as_echo_n "checking for alloca... " >&6; }
   1.311 -+if test "${ac_cv_func_alloca_works+set}" = set; then :
   1.312 -+  $as_echo_n "(cached) " >&6
   1.313 -+else
   1.314 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   1.315 -+/* end confdefs.h.  */
   1.316 -+#ifdef __GNUC__
   1.317 -+# define alloca __builtin_alloca
   1.318 -+#else
   1.319 -+# ifdef _MSC_VER
   1.320 -+#  include <malloc.h>
   1.321 -+#  define alloca _alloca
   1.322 -+# else
   1.323 -+#  ifdef HAVE_ALLOCA_H
   1.324 -+#   include <alloca.h>
   1.325 -+#  else
   1.326 -+#   ifdef _AIX
   1.327 -+ #pragma alloca
   1.328 -+#   else
   1.329 -+#    ifndef alloca /* predefined by HP cc +Olibcalls */
   1.330 -+char *alloca ();
   1.331 -+#    endif
   1.332 -+#   endif
   1.333 -+#  endif
   1.334 -+# endif
   1.335 -+#endif
   1.336 -+
   1.337 -+int
   1.338 -+main ()
   1.339 -+{
   1.340 -+char *p = (char *) alloca (1);
   1.341 -+				    if (p) return 0;
   1.342 -+  ;
   1.343 -+  return 0;
   1.344 -+}
   1.345 -+_ACEOF
   1.346 -+if ac_fn_c_try_link "$LINENO"; then :
   1.347 -+  ac_cv_func_alloca_works=yes
   1.348 -+else
   1.349 -+  ac_cv_func_alloca_works=no
   1.350 -+fi
   1.351 -+rm -f core conftest.err conftest.$ac_objext \
   1.352 -+    conftest$ac_exeext conftest.$ac_ext
   1.353 -+fi
   1.354 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
   1.355 -+$as_echo "$ac_cv_func_alloca_works" >&6; }
   1.356 -+
   1.357 -+if test $ac_cv_func_alloca_works = yes; then
   1.358 -+
   1.359 -+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
   1.360 -+
   1.361 -+else
   1.362 -+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
   1.363 -+# that cause trouble.  Some versions do not even contain alloca or
   1.364 -+# contain a buggy version.  If you still want to use their alloca,
   1.365 -+# use ar to extract alloca.o from them instead of compiling alloca.c.
   1.366 -+
   1.367 -+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
   1.368 -+
   1.369 -+$as_echo "#define C_ALLOCA 1" >>confdefs.h
   1.370 -+
   1.371 -+
   1.372 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
   1.373 -+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
   1.374 -+if test "${ac_cv_os_cray+set}" = set; then :
   1.375 -+  $as_echo_n "(cached) " >&6
   1.376 -+else
   1.377 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   1.378 -+/* end confdefs.h.  */
   1.379 -+#if defined CRAY && ! defined CRAY2
   1.380 -+webecray
   1.381 -+#else
   1.382 -+wenotbecray
   1.383 -+#endif
   1.384 -+
   1.385 -+_ACEOF
   1.386 -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   1.387 -+  $EGREP "webecray" >/dev/null 2>&1; then :
   1.388 -+  ac_cv_os_cray=yes
   1.389 -+else
   1.390 -+  ac_cv_os_cray=no
   1.391 -+fi
   1.392 -+rm -f conftest*
   1.393 -+
   1.394 -+fi
   1.395 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
   1.396 -+$as_echo "$ac_cv_os_cray" >&6; }
   1.397 -+if test $ac_cv_os_cray = yes; then
   1.398 -+  for ac_func in _getb67 GETB67 getb67; do
   1.399 -+    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   1.400 -+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   1.401 -+eval as_val=\$$as_ac_var
   1.402 -+   if test "x$as_val" = x""yes; then :
   1.403 -+
   1.404 -+cat >>confdefs.h <<_ACEOF
   1.405 -+#define CRAY_STACKSEG_END $ac_func
   1.406 -+_ACEOF
   1.407 -+
   1.408 -+    break
   1.409 -+fi
   1.410 -+
   1.411 -+  done
   1.412 -+fi
   1.413 -+
   1.414 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
   1.415 -+$as_echo_n "checking stack direction for C alloca... " >&6; }
   1.416 -+if test "${ac_cv_c_stack_direction+set}" = set; then :
   1.417 -+  $as_echo_n "(cached) " >&6
   1.418 -+else
   1.419 -+  if test "$cross_compiling" = yes; then :
   1.420 -+  ac_cv_c_stack_direction=0
   1.421 -+else
   1.422 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   1.423 -+/* end confdefs.h.  */
   1.424 -+$ac_includes_default
   1.425 -+int
   1.426 -+find_stack_direction ()
   1.427 -+{
   1.428 -+  static char *addr = 0;
   1.429 -+  auto char dummy;
   1.430 -+  if (addr == 0)
   1.431 -+    {
   1.432 -+      addr = &dummy;
   1.433 -+      return find_stack_direction ();
   1.434 -+    }
   1.435 -+  else
   1.436 -+    return (&dummy > addr) ? 1 : -1;
   1.437 -+}
   1.438 -+
   1.439 -+int
   1.440 -+main ()
   1.441 -+{
   1.442 -+  return find_stack_direction () < 0;
   1.443 -+}
   1.444 -+_ACEOF
   1.445 -+if ac_fn_c_try_run "$LINENO"; then :
   1.446 -+  ac_cv_c_stack_direction=1
   1.447 -+else
   1.448 -+  ac_cv_c_stack_direction=-1
   1.449 -+fi
   1.450 -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   1.451 -+  conftest.$ac_objext conftest.beam conftest.$ac_ext
   1.452 -+fi
   1.453 -+
   1.454 -+fi
   1.455 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
   1.456 -+$as_echo "$ac_cv_c_stack_direction" >&6; }
   1.457 -+cat >>confdefs.h <<_ACEOF
   1.458 -+#define STACK_DIRECTION $ac_cv_c_stack_direction
   1.459 -+_ACEOF
   1.460 -+
   1.461 -+
   1.462 -+fi
   1.463 -+
   1.464 -+
   1.465 - 
   1.466 -   for ac_header in stdint.h
   1.467 - do :
   1.468 -@@ -7564,13 +7756,13 @@
   1.469 - else
   1.470 -   lt_cv_nm_interface="BSD nm"
   1.471 -   echo "int some_variable = 0;" > conftest.$ac_ext
   1.472 --  (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
   1.473 -+  (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
   1.474 -   (eval "$ac_compile" 2>conftest.err)
   1.475 -   cat conftest.err >&5
   1.476 --  (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   1.477 -+  (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   1.478 -   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   1.479 -   cat conftest.err >&5
   1.480 --  (eval echo "\"\$as_me:7573: output\"" >&5)
   1.481 -+  (eval echo "\"\$as_me:7765: output\"" >&5)
   1.482 -   cat conftest.out >&5
   1.483 -   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
   1.484 -     lt_cv_nm_interface="MS dumpbin"
   1.485 -@@ -8772,7 +8964,7 @@
   1.486 -   ;;
   1.487 - *-*-irix6*)
   1.488 -   # Find out which ABI we are using.
   1.489 --  echo '#line 8775 "configure"' > conftest.$ac_ext
   1.490 -+  echo '#line 8967 "configure"' > conftest.$ac_ext
   1.491 -   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   1.492 -   (eval $ac_compile) 2>&5
   1.493 -   ac_status=$?
   1.494 -@@ -10032,11 +10224,11 @@
   1.495 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   1.496 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   1.497 -    -e 's:$: $lt_compiler_flag:'`
   1.498 --   (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
   1.499 -+   (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
   1.500 -    (eval "$lt_compile" 2>conftest.err)
   1.501 -    ac_status=$?
   1.502 -    cat conftest.err >&5
   1.503 --   echo "$as_me:10039: \$? = $ac_status" >&5
   1.504 -+   echo "$as_me:10231: \$? = $ac_status" >&5
   1.505 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   1.506 -      # The compiler can only warn and ignore the option if not recognized
   1.507 -      # So say no if there are warnings other than the usual output.
   1.508 -@@ -10371,11 +10563,11 @@
   1.509 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   1.510 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   1.511 -    -e 's:$: $lt_compiler_flag:'`
   1.512 --   (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
   1.513 -+   (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
   1.514 -    (eval "$lt_compile" 2>conftest.err)
   1.515 -    ac_status=$?
   1.516 -    cat conftest.err >&5
   1.517 --   echo "$as_me:10378: \$? = $ac_status" >&5
   1.518 -+   echo "$as_me:10570: \$? = $ac_status" >&5
   1.519 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   1.520 -      # The compiler can only warn and ignore the option if not recognized
   1.521 -      # So say no if there are warnings other than the usual output.
   1.522 -@@ -10476,11 +10668,11 @@
   1.523 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   1.524 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   1.525 -    -e 's:$: $lt_compiler_flag:'`
   1.526 --   (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
   1.527 -+   (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
   1.528 -    (eval "$lt_compile" 2>out/conftest.err)
   1.529 -    ac_status=$?
   1.530 -    cat out/conftest.err >&5
   1.531 --   echo "$as_me:10483: \$? = $ac_status" >&5
   1.532 -+   echo "$as_me:10675: \$? = $ac_status" >&5
   1.533 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   1.534 -    then
   1.535 -      # The compiler can only warn and ignore the option if not recognized
   1.536 -@@ -10531,11 +10723,11 @@
   1.537 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   1.538 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   1.539 -    -e 's:$: $lt_compiler_flag:'`
   1.540 --   (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
   1.541 -+   (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
   1.542 -    (eval "$lt_compile" 2>out/conftest.err)
   1.543 -    ac_status=$?
   1.544 -    cat out/conftest.err >&5
   1.545 --   echo "$as_me:10538: \$? = $ac_status" >&5
   1.546 -+   echo "$as_me:10730: \$? = $ac_status" >&5
   1.547 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   1.548 -    then
   1.549 -      # The compiler can only warn and ignore the option if not recognized
   1.550 -@@ -12915,7 +13107,7 @@
   1.551 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   1.552 -   lt_status=$lt_dlunknown
   1.553 -   cat > conftest.$ac_ext <<_LT_EOF
   1.554 --#line 12918 "configure"
   1.555 -+#line 13110 "configure"
   1.556 - #include "confdefs.h"
   1.557 - 
   1.558 - #if HAVE_DLFCN_H
   1.559 -@@ -13011,7 +13203,7 @@
   1.560 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   1.561 -   lt_status=$lt_dlunknown
   1.562 -   cat > conftest.$ac_ext <<_LT_EOF
   1.563 --#line 13014 "configure"
   1.564 -+#line 13206 "configure"
   1.565 - #include "confdefs.h"
   1.566 - 
   1.567 - #if HAVE_DLFCN_H
   1.568 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   1.569 ---- mpfr-3.0.0-a/mpfr.h	2010-06-23 11:03:20.000000000 +0000
   1.570 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   1.571 -@@ -27,7 +27,7 @@
   1.572 - #define MPFR_VERSION_MAJOR 3
   1.573 - #define MPFR_VERSION_MINOR 0
   1.574 - #define MPFR_VERSION_PATCHLEVEL 0
   1.575 --#define MPFR_VERSION_STRING "3.0.0-p1"
   1.576 -+#define MPFR_VERSION_STRING "3.0.0-p2"
   1.577 - 
   1.578 - /* Macros dealing with MPFR VERSION */
   1.579 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.580 -diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
   1.581 ---- mpfr-3.0.0-a/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   1.582 -+++ mpfr-3.0.0-b/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   1.583 -@@ -960,6 +960,7 @@
   1.584 - red=; grn=; lgn=; blu=; std=
   1.585 - DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   1.586 - ACLOCAL = @ACLOCAL@
   1.587 -+ALLOCA = @ALLOCA@
   1.588 - AMTAR = @AMTAR@
   1.589 - AR = @AR@
   1.590 - AS = @AS@
   1.591 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   1.592 ---- mpfr-3.0.0-a/version.c	2010-06-23 11:03:20.000000000 +0000
   1.593 -+++ mpfr-3.0.0-b/version.c	2010-06-25 13:23:13.000000000 +0000
   1.594 -@@ -25,5 +25,5 @@
   1.595 - const char *
   1.596 - mpfr_get_version (void)
   1.597 - {
   1.598 --  return "3.0.0-p1";
   1.599 -+  return "3.0.0-p2";
   1.600 - }
   1.601 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   1.602 ---- mpfr-3.0.0-a/PATCHES	2010-07-10 00:11:19.000000000 +0000
   1.603 -+++ mpfr-3.0.0-b/PATCHES	2010-07-10 00:12:50.000000000 +0000
   1.604 -@@ -0,0 +1 @@
   1.605 -+gamma_underflow
   1.606 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   1.607 ---- mpfr-3.0.0-a/VERSION	2010-06-25 13:23:13.000000000 +0000
   1.608 -+++ mpfr-3.0.0-b/VERSION	2010-07-10 00:11:53.000000000 +0000
   1.609 -@@ -1 +1 @@
   1.610 --3.0.0-p2
   1.611 -+3.0.0-p3
   1.612 -diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
   1.613 ---- mpfr-3.0.0-a/gamma.c	2010-06-10 11:00:14.000000000 +0000
   1.614 -+++ mpfr-3.0.0-b/gamma.c	2010-07-10 00:11:46.000000000 +0000
   1.615 -@@ -274,7 +274,7 @@
   1.616 -       /* we want an upper bound for x * [log(2-x)-1].
   1.617 -          since x < 0, we need a lower bound on log(2-x) */
   1.618 -       mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
   1.619 --      mpfr_log (xp, xp, MPFR_RNDD);
   1.620 -+      mpfr_log2 (xp, xp, MPFR_RNDD);
   1.621 -       mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
   1.622 -       mpfr_mul (xp, xp, x, MPFR_RNDU);
   1.623 - 
   1.624 -@@ -303,8 +303,8 @@
   1.625 -         {
   1.626 -           mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
   1.627 -           mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
   1.628 --          mpfr_log (tmp, tmp, MPFR_RNDU);
   1.629 --          mpfr_add (tmp, tmp, xp, MPFR_RNDU);
   1.630 -+          mpfr_log2 (tmp, tmp, MPFR_RNDU);
   1.631 -+          mpfr_add (xp, tmp, xp, MPFR_RNDU);
   1.632 -           underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
   1.633 -         }
   1.634 - 
   1.635 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   1.636 ---- mpfr-3.0.0-a/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   1.637 -+++ mpfr-3.0.0-b/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   1.638 -@@ -27,7 +27,7 @@
   1.639 - #define MPFR_VERSION_MAJOR 3
   1.640 - #define MPFR_VERSION_MINOR 0
   1.641 - #define MPFR_VERSION_PATCHLEVEL 0
   1.642 --#define MPFR_VERSION_STRING "3.0.0-p2"
   1.643 -+#define MPFR_VERSION_STRING "3.0.0-p3"
   1.644 - 
   1.645 - /* Macros dealing with MPFR VERSION */
   1.646 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.647 -diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
   1.648 ---- mpfr-3.0.0-a/tests/tgamma.c	2010-06-10 11:00:13.000000000 +0000
   1.649 -+++ mpfr-3.0.0-b/tests/tgamma.c	2010-07-10 00:11:46.000000000 +0000
   1.650 -@@ -461,6 +461,20 @@
   1.651 -   mpfr_clear (x);
   1.652 - }
   1.653 - 
   1.654 -+/* bug found by Stathis, only occurs on 32-bit machines */
   1.655 -+static void
   1.656 -+test20100709 (void)
   1.657 -+{
   1.658 -+  mpfr_t x;
   1.659 -+  int inex;
   1.660 -+
   1.661 -+  mpfr_init2 (x, 100);
   1.662 -+  mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
   1.663 -+  inex = mpfr_gamma (x, x, MPFR_RNDN);
   1.664 -+  MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
   1.665 -+  mpfr_clear (x);
   1.666 -+}
   1.667 -+
   1.668 - int
   1.669 - main (int argc, char *argv[])
   1.670 - {
   1.671 -@@ -471,6 +485,7 @@
   1.672 -   test_generic (2, 100, 2);
   1.673 -   gamma_integer ();
   1.674 -   test20071231 ();
   1.675 -+  test20100709 ();
   1.676 - 
   1.677 -   data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
   1.678 - 
   1.679 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   1.680 ---- mpfr-3.0.0-a/version.c	2010-06-25 13:23:13.000000000 +0000
   1.681 -+++ mpfr-3.0.0-b/version.c	2010-07-10 00:11:53.000000000 +0000
   1.682 -@@ -25,5 +25,5 @@
   1.683 - const char *
   1.684 - mpfr_get_version (void)
   1.685 - {
   1.686 --  return "3.0.0-p2";
   1.687 -+  return "3.0.0-p3";
   1.688 - }
   1.689 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   1.690 ---- mpfr-3.0.0-a/PATCHES	2010-09-07 08:44:01.000000000 +0000
   1.691 -+++ mpfr-3.0.0-b/PATCHES	2010-09-07 08:48:46.000000000 +0000
   1.692 -@@ -0,0 +1 @@
   1.693 -+mpfr_cmp/set_ui/si
   1.694 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   1.695 ---- mpfr-3.0.0-a/VERSION	2010-07-10 00:11:53.000000000 +0000
   1.696 -+++ mpfr-3.0.0-b/VERSION	2010-09-07 08:46:06.000000000 +0000
   1.697 -@@ -1 +1 @@
   1.698 --3.0.0-p3
   1.699 -+3.0.0-p4
   1.700 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   1.701 ---- mpfr-3.0.0-a/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   1.702 -+++ mpfr-3.0.0-b/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   1.703 -@@ -27,7 +27,7 @@
   1.704 - #define MPFR_VERSION_MAJOR 3
   1.705 - #define MPFR_VERSION_MINOR 0
   1.706 - #define MPFR_VERSION_PATCHLEVEL 0
   1.707 --#define MPFR_VERSION_STRING "3.0.0-p3"
   1.708 -+#define MPFR_VERSION_STRING "3.0.0-p4"
   1.709 - 
   1.710 - /* Macros dealing with MPFR VERSION */
   1.711 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.712 -@@ -798,35 +798,45 @@
   1.713 -      anyway. Checking with other ICC versions is needed. Possibly detect
   1.714 -      whether warnings are produced or not with a configure test.
   1.715 -    + Remove C++ too, since it complains too much. */
   1.716 -+/* Added casts to improve robustness in case of undefined behavior and
   1.717 -+   compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
   1.718 -+   use such extensions, but these macros will be used by 3rd-party code,
   1.719 -+   where such extensions may be required.
   1.720 -+   Moreover casts to unsigned long have been added to avoid warnings in
   1.721 -+   programs that use MPFR and are compiled with -Wconversion; such casts
   1.722 -+   are OK since if X is a constant expression, then (unsigned long) X is
   1.723 -+   also a constant expression, so that the optimizations still work. */
   1.724 - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
   1.725 - #if (__GNUC__ >= 2)
   1.726 - #undef mpfr_cmp_ui
   1.727 --/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
   1.728 --#define mpfr_cmp_ui(_f,_u)                 \
   1.729 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   1.730 --   mpfr_sgn (_f) :                         \
   1.731 --   mpfr_cmp_ui_2exp ((_f),(_u),0))
   1.732 -+/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
   1.733 -+   But warning! mpfr_sgn is specified as a macro in the API, thus the macro
   1.734 -+   mustn't be used if side effects are possible, like here. */
   1.735 -+#define mpfr_cmp_ui(_f,_u)                                      \
   1.736 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   1.737 -+   (mpfr_sgn) (_f) :                                            \
   1.738 -+   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
   1.739 - #undef mpfr_cmp_si
   1.740 --#define mpfr_cmp_si(_f,_s)                 \
   1.741 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   1.742 --   mpfr_cmp_ui ((_f), (_s)) :              \
   1.743 --   mpfr_cmp_si_2exp ((_f), (_s), 0))
   1.744 -+#define mpfr_cmp_si(_f,_s)                              \
   1.745 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
   1.746 -+   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
   1.747 -+   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
   1.748 - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
   1.749 - #undef mpfr_set_ui
   1.750 --#define mpfr_set_ui(_f,_u,_r)              \
   1.751 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   1.752 --   __extension__ ({                        \
   1.753 --     mpfr_ptr _p = (_f);                   \
   1.754 --     _p->_mpfr_sign = 1;                   \
   1.755 --     _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
   1.756 --     (void) (_r); 0; }) :                  \
   1.757 --   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
   1.758 -+#define mpfr_set_ui(_f,_u,_r)                                   \
   1.759 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   1.760 -+   __extension__ ({                                             \
   1.761 -+       mpfr_ptr _p = (_f);                                      \
   1.762 -+       _p->_mpfr_sign = 1;                                      \
   1.763 -+       _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
   1.764 -+       (void) (_r); 0; }) :                                     \
   1.765 -+   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
   1.766 - #endif
   1.767 - #undef mpfr_set_si
   1.768 --#define mpfr_set_si(_f,_s,_r)              \
   1.769 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   1.770 --   mpfr_set_ui ((_f), (_s), (_r)) :        \
   1.771 --   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
   1.772 -+#define mpfr_set_si(_f,_s,_r)                                   \
   1.773 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
   1.774 -+   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
   1.775 -+   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
   1.776 - #endif
   1.777 - #endif
   1.778 - 
   1.779 -diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
   1.780 ---- mpfr-3.0.0-a/tests/tcmp_ui.c	2010-06-10 11:00:13.000000000 +0000
   1.781 -+++ mpfr-3.0.0-b/tests/tcmp_ui.c	2010-09-07 08:45:12.000000000 +0000
   1.782 -@@ -88,6 +88,126 @@
   1.783 -   mpfr_clear (x);
   1.784 - }
   1.785 - 
   1.786 -+/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
   1.787 -+   with __builtin_constant_p for GCC, check that side effects are
   1.788 -+   handled correctly. */
   1.789 -+static void
   1.790 -+check_macros (void)
   1.791 -+{
   1.792 -+  mpfr_t x;
   1.793 -+  int c;
   1.794 -+
   1.795 -+  mpfr_init2 (x, 32);
   1.796 -+
   1.797 -+  c = 0;
   1.798 -+  mpfr_set_ui (x, 17, MPFR_RNDN);
   1.799 -+  if (mpfr_cmp_ui (x, 17) != 0)
   1.800 -+    {
   1.801 -+      printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
   1.802 -+      exit (1);
   1.803 -+    }
   1.804 -+  if (mpfr_cmp_ui (x, (c++, 17)) != 0)
   1.805 -+    {
   1.806 -+      printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
   1.807 -+      exit (1);
   1.808 -+    }
   1.809 -+  if (c != 1)
   1.810 -+    {
   1.811 -+      printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
   1.812 -+              "(c = %d instead of 1)\n", c);
   1.813 -+      exit (1);
   1.814 -+    }
   1.815 -+  if (mpfr_cmp_si (x, 17) != 0)
   1.816 -+    {
   1.817 -+      printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
   1.818 -+      exit (1);
   1.819 -+    }
   1.820 -+  if (mpfr_cmp_si (x, (c++, 17)) != 0)
   1.821 -+    {
   1.822 -+      printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
   1.823 -+      exit (1);
   1.824 -+    }
   1.825 -+  if (c != 2)
   1.826 -+    {
   1.827 -+      printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
   1.828 -+              "(c = %d instead of 2)\n", c);
   1.829 -+      exit (1);
   1.830 -+    }
   1.831 -+
   1.832 -+  c = 0;
   1.833 -+  mpfr_set_ui (x, 0, MPFR_RNDN);
   1.834 -+  if (mpfr_cmp_ui (x, 0) != 0)
   1.835 -+    {
   1.836 -+      printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
   1.837 -+      exit (1);
   1.838 -+    }
   1.839 -+  if (mpfr_cmp_ui (x, (c++, 0)) != 0)
   1.840 -+    {
   1.841 -+      printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
   1.842 -+      exit (1);
   1.843 -+    }
   1.844 -+  if (c != 1)
   1.845 -+    {
   1.846 -+      printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
   1.847 -+              "(c = %d instead of 1)\n", c);
   1.848 -+      exit (1);
   1.849 -+    }
   1.850 -+  if (mpfr_cmp_si (x, 0) != 0)
   1.851 -+    {
   1.852 -+      printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
   1.853 -+      exit (1);
   1.854 -+    }
   1.855 -+  if (mpfr_cmp_si (x, (c++, 0)) != 0)
   1.856 -+    {
   1.857 -+      printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
   1.858 -+      exit (1);
   1.859 -+    }
   1.860 -+  if (c != 2)
   1.861 -+    {
   1.862 -+      printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
   1.863 -+              "(c = %d instead of 2)\n", c);
   1.864 -+      exit (1);
   1.865 -+    }
   1.866 -+
   1.867 -+  mpfr_clear (x);
   1.868 -+}
   1.869 -+
   1.870 -+/* Bug in r7114 */
   1.871 -+static void
   1.872 -+test_macros (void)
   1.873 -+{
   1.874 -+  mpfr_t x[3];
   1.875 -+  mpfr_ptr p;
   1.876 -+
   1.877 -+  mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
   1.878 -+  mpfr_set_ui (x[0], 0, MPFR_RNDN);
   1.879 -+  p = x[0];
   1.880 -+  if (mpfr_cmp_ui (p++, 0) != 0)
   1.881 -+    {
   1.882 -+      printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
   1.883 -+      exit (1);
   1.884 -+    }
   1.885 -+  if (p != x[1])
   1.886 -+    {
   1.887 -+      printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
   1.888 -+              (int) (p - x[0]));
   1.889 -+      exit (1);
   1.890 -+    }
   1.891 -+  p = x[0];
   1.892 -+  if (mpfr_cmp_si (p++, 0) != 0)
   1.893 -+    {
   1.894 -+      printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
   1.895 -+      exit (1);
   1.896 -+    }
   1.897 -+  if (p != x[1])
   1.898 -+    {
   1.899 -+      printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
   1.900 -+              (int) (p - x[0]));
   1.901 -+      exit (1);
   1.902 -+    }
   1.903 -+  mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
   1.904 -+}
   1.905 -+
   1.906 - int
   1.907 - main (void)
   1.908 - {
   1.909 -@@ -216,6 +336,8 @@
   1.910 -   mpfr_clear (x);
   1.911 - 
   1.912 -   check_nan ();
   1.913 -+  check_macros ();
   1.914 -+  test_macros ();
   1.915 - 
   1.916 -   tests_end_mpfr ();
   1.917 -   return 0;
   1.918 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   1.919 ---- mpfr-3.0.0-a/version.c	2010-07-10 00:11:53.000000000 +0000
   1.920 -+++ mpfr-3.0.0-b/version.c	2010-09-07 08:46:06.000000000 +0000
   1.921 -@@ -25,5 +25,5 @@
   1.922 - const char *
   1.923 - mpfr_get_version (void)
   1.924 - {
   1.925 --  return "3.0.0-p3";
   1.926 -+  return "3.0.0-p4";
   1.927 - }
   1.928 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   1.929 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 20:28:38.000000000 +0000
   1.930 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:28:38.000000000 +0000
   1.931 -@@ -0,0 +1 @@
   1.932 -+tcan_round
   1.933 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   1.934 ---- mpfr-3.0.0-a/VERSION	2010-09-07 08:46:06.000000000 +0000
   1.935 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 20:28:38.000000000 +0000
   1.936 -@@ -1 +1 @@
   1.937 --3.0.0-p4
   1.938 -+3.0.0-p5
   1.939 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   1.940 ---- mpfr-3.0.0-a/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   1.941 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   1.942 -@@ -27,7 +27,7 @@
   1.943 - #define MPFR_VERSION_MAJOR 3
   1.944 - #define MPFR_VERSION_MINOR 0
   1.945 - #define MPFR_VERSION_PATCHLEVEL 0
   1.946 --#define MPFR_VERSION_STRING "3.0.0-p4"
   1.947 -+#define MPFR_VERSION_STRING "3.0.0-p5"
   1.948 - 
   1.949 - /* Macros dealing with MPFR VERSION */
   1.950 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.951 -diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
   1.952 ---- mpfr-3.0.0-a/tests/tcan_round.c	2010-06-10 11:00:13.000000000 +0000
   1.953 -+++ mpfr-3.0.0-b/tests/tcan_round.c	2010-10-21 20:28:38.000000000 +0000
   1.954 -@@ -41,7 +41,7 @@
   1.955 -       /* avoid mpn_random which leaks memory */
   1.956 -       for (i = 0; i < n; i++)
   1.957 -         buf[i] = randlimb ();
   1.958 --      p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   1.959 -+      p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   1.960 -       err = p + randlimb () % GMP_NUMB_BITS;
   1.961 -       r1 = mpfr_round_p (buf, n, err, p);
   1.962 -       r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
   1.963 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   1.964 ---- mpfr-3.0.0-a/version.c	2010-09-07 08:46:06.000000000 +0000
   1.965 -+++ mpfr-3.0.0-b/version.c	2010-10-21 20:28:38.000000000 +0000
   1.966 -@@ -25,5 +25,5 @@
   1.967 - const char *
   1.968 - mpfr_get_version (void)
   1.969 - {
   1.970 --  return "3.0.0-p4";
   1.971 -+  return "3.0.0-p5";
   1.972 - }
   1.973 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   1.974 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 20:59:32.000000000 +0000
   1.975 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:59:32.000000000 +0000
   1.976 -@@ -0,0 +1 @@
   1.977 -+mpfr_sub1
   1.978 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   1.979 ---- mpfr-3.0.0-a/VERSION	2010-10-21 20:28:38.000000000 +0000
   1.980 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 20:59:32.000000000 +0000
   1.981 -@@ -1 +1 @@
   1.982 --3.0.0-p5
   1.983 -+3.0.0-p6
   1.984 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   1.985 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   1.986 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:59:32.000000000 +0000
   1.987 -@@ -27,7 +27,7 @@
   1.988 - #define MPFR_VERSION_MAJOR 3
   1.989 - #define MPFR_VERSION_MINOR 0
   1.990 - #define MPFR_VERSION_PATCHLEVEL 0
   1.991 --#define MPFR_VERSION_STRING "3.0.0-p5"
   1.992 -+#define MPFR_VERSION_STRING "3.0.0-p6"
   1.993 - 
   1.994 - /* Macros dealing with MPFR VERSION */
   1.995 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   1.996 -diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
   1.997 ---- mpfr-3.0.0-a/sub1.c	2010-06-10 11:00:14.000000000 +0000
   1.998 -+++ mpfr-3.0.0-b/sub1.c	2010-10-21 20:59:32.000000000 +0000
   1.999 -@@ -37,7 +37,9 @@
  1.1000 -   mp_size_t cancel2, an, bn, cn, cn0;
  1.1001 -   mp_limb_t *ap, *bp, *cp;
  1.1002 -   mp_limb_t carry, bb, cc, borrow = 0;
  1.1003 --  int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
  1.1004 -+  int inexact, shift_b, shift_c, add_exp = 0;
  1.1005 -+  int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
  1.1006 -+                      negative if low(b) < low(c), positive if low(b)>low(c) */
  1.1007 -   int sh, k;
  1.1008 -   MPFR_TMP_DECL(marker);
  1.1009 - 
  1.1010 -@@ -196,7 +198,8 @@
  1.1011 -     }
  1.1012 - 
  1.1013 - #ifdef DEBUG
  1.1014 --  printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
  1.1015 -+  printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
  1.1016 -+          mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
  1.1017 -           (unsigned long) diff_exp);
  1.1018 - #endif
  1.1019 - 
  1.1020 -@@ -307,17 +310,18 @@
  1.1021 -     {
  1.1022 -       if (MPFR_LIKELY(sh))
  1.1023 -         {
  1.1024 --          is_exact = (carry == 0);
  1.1025 -           /* can decide except when carry = 2^(sh-1) [middle]
  1.1026 -              or carry = 0 [truncate, but cannot decide inexact flag] */
  1.1027 --          down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
  1.1028 -           if (carry > (MPFR_LIMB_ONE << (sh - 1)))
  1.1029 -             goto add_one_ulp;
  1.1030 --          else if ((0 < carry) && down)
  1.1031 -+          else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
  1.1032 -             {
  1.1033 -               inexact = -1; /* result if smaller than exact value */
  1.1034 -               goto truncate;
  1.1035 -             }
  1.1036 -+          /* now carry = 2^(sh-1), in which case cmp_low=2,
  1.1037 -+             or carry = 0, in which case cmp_low=0 */
  1.1038 -+          cmp_low = (carry == 0) ? 0 : 2;
  1.1039 -         }
  1.1040 -     }
  1.1041 -   else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
  1.1042 -@@ -344,12 +348,32 @@
  1.1043 -   cn -= (long int) an + cancel2;
  1.1044 - 
  1.1045 - #ifdef DEBUG
  1.1046 --  printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
  1.1047 -+  printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
  1.1048 -           sh, (unsigned long) carry, (long) bn, (long) cn);
  1.1049 - #endif
  1.1050 - 
  1.1051 -+  /* for rounding to nearest, we couldn't conclude up to here in the following
  1.1052 -+     cases:
  1.1053 -+     1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
  1.1054 -+        or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
  1.1055 -+     2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
  1.1056 -+        -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
  1.1057 -+        we can't decide the rounding, in that case cmp_low=2:
  1.1058 -+        either we truncate and flag=-1, or we add one ulp and flag=1
  1.1059 -+     3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
  1.1060 -+        truncate but we can't decide the ternary value, here cmp_low=0:
  1.1061 -+        -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
  1.1062 -+        we always truncate and inexact can be any of -1,0,1
  1.1063 -+  */
  1.1064 -+
  1.1065 -+  /* note: here cn might exceed cn0, in which case we consider a zero limb */
  1.1066 -   for (k = 0; (bn > 0) || (cn > 0); k = 1)
  1.1067 -     {
  1.1068 -+      /* if cmp_low < 0, we know low(b) - low(c) < 0
  1.1069 -+         if cmp_low > 0, we know low(b) - low(c) > 0
  1.1070 -+            (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
  1.1071 -+         if cmp_low = 0, so far low(b) - low(c) = 0 */
  1.1072 -+
  1.1073 -       /* get next limbs */
  1.1074 -       bb = (bn > 0) ? bp[--bn] : 0;
  1.1075 -       if ((cn > 0) && (cn-- <= cn0))
  1.1076 -@@ -357,76 +381,115 @@
  1.1077 -       else
  1.1078 -         cc = 0;
  1.1079 - 
  1.1080 --      /* down is set when low(b) < low(c) */
  1.1081 --      if (down == 0)
  1.1082 --        down = (bb < cc);
  1.1083 -+      /* cmp_low compares low(b) and low(c) */
  1.1084 -+      if (cmp_low == 0) /* case 1 or 3 */
  1.1085 -+        cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
  1.1086 -+
  1.1087 -+      /* Case 1 for k=0 splits into 7 subcases:
  1.1088 -+         1a: bb > cc + half
  1.1089 -+         1b: bb = cc + half
  1.1090 -+         1c: 0 < bb - cc < half
  1.1091 -+         1d: bb = cc
  1.1092 -+         1e: -half < bb - cc < 0
  1.1093 -+         1f: bb - cc = -half
  1.1094 -+         1g: bb - cc < -half
  1.1095 -+
  1.1096 -+         Case 2 splits into 3 subcases:
  1.1097 -+         2a: bb > cc
  1.1098 -+         2b: bb = cc
  1.1099 -+         2c: bb < cc
  1.1100 -+
  1.1101 -+         Case 3 splits into 3 subcases:
  1.1102 -+         3a: bb > cc
  1.1103 -+         3b: bb = cc
  1.1104 -+         3c: bb < cc
  1.1105 -+      */
  1.1106 - 
  1.1107 -       /* the case rounding to nearest with sh=0 is special since one couldn't
  1.1108 -          subtract above 1/2 ulp in the trailing limb of the result */
  1.1109 --      if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
  1.1110 -+      if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
  1.1111 -         {
  1.1112 -           mp_limb_t half = MPFR_LIMB_HIGHBIT;
  1.1113 - 
  1.1114 --          is_exact = (bb == cc);
  1.1115 --
  1.1116 -           /* add one ulp if bb > cc + half
  1.1117 -              truncate if cc - half < bb < cc + half
  1.1118 -              sub one ulp if bb < cc - half
  1.1119 -           */
  1.1120 - 
  1.1121 --          if (down)
  1.1122 -+          if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
  1.1123 -+                              cases 1e, 1f and 1g */
  1.1124 -             {
  1.1125 -               if (cc >= half)
  1.1126 -                 cc -= half;
  1.1127 --              else
  1.1128 -+              else /* since bb < cc < half, bb+half < 2*half */
  1.1129 -                 bb += half;
  1.1130 -+              /* now we have bb < cc + half:
  1.1131 -+                 we have to subtract one ulp if bb < cc,
  1.1132 -+                 and truncate if bb > cc */
  1.1133 -             }
  1.1134 --          else /* bb >= cc */
  1.1135 -+          else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
  1.1136 -             {
  1.1137 -               if (cc < half)
  1.1138 -                 cc += half;
  1.1139 --              else
  1.1140 -+              else /* since bb >= cc >= half, bb - half >= 0 */
  1.1141 -                 bb -= half;
  1.1142 -+              /* now we have bb > cc - half: we have to add one ulp if bb > cc,
  1.1143 -+                 and truncate if bb < cc */
  1.1144 -+              if (cmp_low > 0)
  1.1145 -+                cmp_low = 2;
  1.1146 -             }
  1.1147 -         }
  1.1148 - 
  1.1149 - #ifdef DEBUG
  1.1150 --      printf ("    bb=%lu cc=%lu down=%d is_exact=%d\n",
  1.1151 --              (unsigned long) bb, (unsigned long) cc, down, is_exact);
  1.1152 -+      printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
  1.1153 -+              (unsigned long) bb, (unsigned long) cc, cmp_low);
  1.1154 - #endif
  1.1155 --      if (bb < cc)
  1.1156 -+      if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
  1.1157 -+                          one ulp */
  1.1158 -         {
  1.1159 -           if (rnd_mode == MPFR_RNDZ)
  1.1160 --            goto sub_one_ulp;
  1.1161 -+            goto sub_one_ulp; /* set inexact=-1 */
  1.1162 -           else if (rnd_mode != MPFR_RNDN) /* round away */
  1.1163 -             {
  1.1164 -               inexact = 1;
  1.1165 -               goto truncate;
  1.1166 -             }
  1.1167 --          else /* round to nearest: special case here since for sh=k=0
  1.1168 --                  bb = bb0 - MPFR_LIMB_HIGHBIT */
  1.1169 -+          else /* round to nearest */
  1.1170 -             {
  1.1171 --              if (is_exact && sh == 0)
  1.1172 --                {
  1.1173 --                  /* For k=0 we can't decide exactness since it may depend
  1.1174 --                     from low order bits.
  1.1175 --                     For k=1, the first low limbs matched: low(b)-low(c)<0. */
  1.1176 --                  if (k)
  1.1177 --                    {
  1.1178 --                      inexact = 1;
  1.1179 --                      goto truncate;
  1.1180 --                    }
  1.1181 --                }
  1.1182 --              else if (down && sh == 0)
  1.1183 --                goto sub_one_ulp;
  1.1184 --              else
  1.1185 --                {
  1.1186 --                  inexact = (is_exact) ? 1 : -1;
  1.1187 -+              /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
  1.1188 -+                 whatever the value of sh.
  1.1189 -+                 If sh>0, then cmp_low < 0 implies that the initial neglected
  1.1190 -+                 sh bits were 0 (otherwise cmp_low=2 initially), thus the
  1.1191 -+                 weight of the new bits is less than 0.5 ulp too.
  1.1192 -+                 If k > 0 (and sh=0) this means that either the first neglected
  1.1193 -+                 limbs bb and cc were equal (thus cmp_low was 0 for k=0),
  1.1194 -+                 or we had bb - cc = -0.5 ulp or 0.5 ulp.
  1.1195 -+                 The last case is not possible here since we would have
  1.1196 -+                 cmp_low > 0 which is sticky.
  1.1197 -+                 In the first case (where we have cmp_low = -1), we truncate,
  1.1198 -+                 whereas in the 2nd case we have cmp_low = -2 and we subtract
  1.1199 -+                 one ulp.
  1.1200 -+              */
  1.1201 -+              if (bb > cc || sh > 0 || cmp_low == -1)
  1.1202 -+                {  /* -0.5 ulp < low(b)-low(c) < 0,
  1.1203 -+                      bb > cc corresponds to cases 1e and 1f1
  1.1204 -+                      sh > 0 corresponds to cases 3c and 3b3
  1.1205 -+                      cmp_low = -1 corresponds to case 1d3 (also 3b3) */
  1.1206 -+                  inexact = 1;
  1.1207 -                   goto truncate;
  1.1208 -                 }
  1.1209 -+              else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
  1.1210 -+                                   this corresponds to cases 1g and 1f3 */
  1.1211 -+                goto sub_one_ulp;
  1.1212 -+              /* the only case where we can't conclude is sh=0 and bb=cc,
  1.1213 -+                 i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
  1.1214 -+                 we don't know if we must truncate or subtract one ulp.
  1.1215 -+                 Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
  1.1216 -+                 now, since low(b) - low(c) > 1/2^sh */
  1.1217 -             }
  1.1218 -         }
  1.1219 --      else if (bb > cc)
  1.1220 -+      else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
  1.1221 -+                               add one ulp */
  1.1222 -         {
  1.1223 -           if (rnd_mode == MPFR_RNDZ)
  1.1224 -             {
  1.1225 -@@ -437,34 +500,70 @@
  1.1226 -             goto add_one_ulp;
  1.1227 -           else /* round to nearest */
  1.1228 -             {
  1.1229 --              if (is_exact)
  1.1230 -+              if (bb > cc)
  1.1231 -                 {
  1.1232 --                  inexact = -1;
  1.1233 --                  goto truncate;
  1.1234 -+                  /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
  1.1235 -+                     and similarly when cmp_low=2 */
  1.1236 -+                  if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
  1.1237 -+                    goto add_one_ulp;
  1.1238 -+                  /* sh > 0 and cmp_low > 0: this implies that the sh initial
  1.1239 -+                     neglected bits were 0, and the remaining low(b)-low(c)>0,
  1.1240 -+                     but its weight is less than 0.5 ulp */
  1.1241 -+                  else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
  1.1242 -+                          cases 3a, 1d1 and 3b1 */
  1.1243 -+                    {
  1.1244 -+                      inexact = -1;
  1.1245 -+                      goto truncate;
  1.1246 -+                    }
  1.1247 -                 }
  1.1248 --              else if (down)
  1.1249 -+              else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
  1.1250 -+                                   1b3, 2b3 and 2c */
  1.1251 -                 {
  1.1252 --                  inexact = 1;
  1.1253 -+                  inexact = -1;
  1.1254 -                   goto truncate;
  1.1255 -                 }
  1.1256 --              else
  1.1257 --                goto add_one_ulp;
  1.1258 -+              /* the only case where we can't conclude is bb=cc, i.e.,
  1.1259 -+                 low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
  1.1260 -+                 if we must truncate or add one ulp. */
  1.1261 -             }
  1.1262 -         }
  1.1263 -+      /* after k=0, we cannot conclude in the following cases, we split them
  1.1264 -+         according to the values of bb and cc for k=1:
  1.1265 -+         1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
  1.1266 -+             1b1. bb > cc: add one ulp, inex = 1
  1.1267 -+             1b2: bb = cc: cannot conclude
  1.1268 -+             1b3: bb < cc: truncate, inex = -1
  1.1269 -+         1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
  1.1270 -+             1d1: bb > cc: truncate, inex = -1
  1.1271 -+             1d2: bb = cc: cannot conclude
  1.1272 -+             1d3: bb < cc: truncate, inex = +1
  1.1273 -+         1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
  1.1274 -+             1f1: bb > cc: truncate, inex = +1
  1.1275 -+             1f2: bb = cc: cannot conclude
  1.1276 -+             1f3: bb < cc: sub one ulp, inex = -1
  1.1277 -+         2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
  1.1278 -+             2b1. bb > cc: add one ulp, inex = 1
  1.1279 -+             2b2: bb = cc: cannot conclude
  1.1280 -+             2b3: bb < cc: truncate, inex = -1
  1.1281 -+         3b. sh > 0 and cmp_low = 0 [around 0]
  1.1282 -+             3b1. bb > cc: truncate, inex = -1
  1.1283 -+             3b2: bb = cc: cannot conclude
  1.1284 -+             3b3: bb < cc: truncate, inex = +1
  1.1285 -+      */
  1.1286 -     }
  1.1287 - 
  1.1288 --  if ((rnd_mode == MPFR_RNDN) && !is_exact)
  1.1289 -+  if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
  1.1290 -     {
  1.1291 -       /* even rounding rule */
  1.1292 -       if ((ap[0] >> sh) & 1)
  1.1293 -         {
  1.1294 --          if (down)
  1.1295 -+          if (cmp_low < 0)
  1.1296 -             goto sub_one_ulp;
  1.1297 -           else
  1.1298 -             goto add_one_ulp;
  1.1299 -         }
  1.1300 -       else
  1.1301 --        inexact = (down) ? 1 : -1;
  1.1302 -+        inexact = (cmp_low > 0) ? -1 : 1;
  1.1303 -     }
  1.1304 -   else
  1.1305 -     inexact = 0;
  1.1306 -diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
  1.1307 ---- mpfr-3.0.0-a/tests/tfma.c	2010-06-10 11:00:13.000000000 +0000
  1.1308 -+++ mpfr-3.0.0-b/tests/tfma.c	2010-10-21 20:59:32.000000000 +0000
  1.1309 -@@ -337,6 +337,94 @@
  1.1310 -   mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
  1.1311 - }
  1.1312 - 
  1.1313 -+static void
  1.1314 -+bug20101018 (void)
  1.1315 -+{
  1.1316 -+  mpfr_t x, y, z, t, u;
  1.1317 -+  int i;
  1.1318 -+
  1.1319 -+  mpfr_init2 (x, 64);
  1.1320 -+  mpfr_init2 (y, 64);
  1.1321 -+  mpfr_init2 (z, 64);
  1.1322 -+  mpfr_init2 (t, 64);
  1.1323 -+  mpfr_init2 (u, 64);
  1.1324 -+
  1.1325 -+  mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
  1.1326 -+  mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
  1.1327 -+  mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
  1.1328 -+  mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
  1.1329 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  1.1330 -+  if (mpfr_cmp (u, t) != 0)
  1.1331 -+    {
  1.1332 -+      printf ("Wrong result in bug20101018 (a)\n");
  1.1333 -+      printf ("Expected ");
  1.1334 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  1.1335 -+      printf ("\nGot      ");
  1.1336 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  1.1337 -+      printf ("\n");
  1.1338 -+      exit (1);
  1.1339 -+    }
  1.1340 -+  if (i <= 0)
  1.1341 -+    {
  1.1342 -+      printf ("Wrong ternary value in bug20101018 (a)\n");
  1.1343 -+      printf ("Expected > 0\n");
  1.1344 -+      printf ("Got      %d\n", i);
  1.1345 -+      exit (1);
  1.1346 -+    }
  1.1347 -+
  1.1348 -+  mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
  1.1349 -+  mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
  1.1350 -+  mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
  1.1351 -+  mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
  1.1352 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  1.1353 -+  if (mpfr_cmp (u, t) != 0)
  1.1354 -+    {
  1.1355 -+      printf ("Wrong result in bug20101018 (b)\n");
  1.1356 -+      printf ("Expected ");
  1.1357 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  1.1358 -+      printf ("\nGot      ");
  1.1359 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  1.1360 -+      printf ("\n");
  1.1361 -+      exit (1);
  1.1362 -+    }
  1.1363 -+  if (i <= 0)
  1.1364 -+    {
  1.1365 -+      printf ("Wrong ternary value in bug20101018 (b)\n");
  1.1366 -+      printf ("Expected > 0\n");
  1.1367 -+      printf ("Got      %d\n", i);
  1.1368 -+      exit (1);
  1.1369 -+    }
  1.1370 -+
  1.1371 -+  mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
  1.1372 -+  mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
  1.1373 -+  mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
  1.1374 -+  mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
  1.1375 -+  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  1.1376 -+  if (mpfr_cmp (u, t) != 0)
  1.1377 -+    {
  1.1378 -+      printf ("Wrong result in bug20101018 (c)\n");
  1.1379 -+      printf ("Expected ");
  1.1380 -+      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  1.1381 -+      printf ("\nGot      ");
  1.1382 -+      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  1.1383 -+      printf ("\n");
  1.1384 -+      exit (1);
  1.1385 -+    }
  1.1386 -+  if (i <= 0)
  1.1387 -+    {
  1.1388 -+      printf ("Wrong ternary value in bug20101018 (c)\n");
  1.1389 -+      printf ("Expected > 0\n");
  1.1390 -+      printf ("Got      %d\n", i);
  1.1391 -+      exit (1);
  1.1392 -+    }
  1.1393 -+
  1.1394 -+  mpfr_clear (x);
  1.1395 -+  mpfr_clear (y);
  1.1396 -+  mpfr_clear (z);
  1.1397 -+  mpfr_clear (t);
  1.1398 -+  mpfr_clear (u);
  1.1399 -+}
  1.1400 -+
  1.1401 - int
  1.1402 - main (int argc, char *argv[])
  1.1403 - {
  1.1404 -@@ -345,6 +433,8 @@
  1.1405 - 
  1.1406 -   tests_start_mpfr ();
  1.1407 - 
  1.1408 -+  bug20101018 ();
  1.1409 -+
  1.1410 -   mpfr_init (x);
  1.1411 -   mpfr_init (s);
  1.1412 -   mpfr_init (y);
  1.1413 -diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
  1.1414 ---- mpfr-3.0.0-a/tests/tsub.c	2010-06-10 11:00:13.000000000 +0000
  1.1415 -+++ mpfr-3.0.0-b/tests/tsub.c	2010-10-21 20:59:32.000000000 +0000
  1.1416 -@@ -201,6 +201,8 @@
  1.1417 -   if (mpfr_cmp (z, x))
  1.1418 -     {
  1.1419 -       printf ("Error in mpfr_sub (2)\n");
  1.1420 -+      printf ("Expected "); mpfr_print_binary (x); puts ("");
  1.1421 -+      printf ("Got      "); mpfr_print_binary (z); puts ("");
  1.1422 -       exit (1);
  1.1423 -     }
  1.1424 -   mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
  1.1425 -@@ -478,6 +480,156 @@
  1.1426 -   mpfr_clear (u);
  1.1427 - }
  1.1428 - 
  1.1429 -+/* Bug found by Jakub Jelinek
  1.1430 -+ * http://bugzilla.redhat.com/643657
  1.1431 -+ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
  1.1432 -+ * The consequence can be either an assertion failure (i = 2 in the
  1.1433 -+ * testcase below, in debug mode) or an incorrectly rounded value.
  1.1434 -+ */
  1.1435 -+static void
  1.1436 -+bug20101017 (void)
  1.1437 -+{
  1.1438 -+  mpfr_t a, b, c;
  1.1439 -+  int inex;
  1.1440 -+  int i;
  1.1441 -+
  1.1442 -+  mpfr_init2 (a, GMP_NUMB_BITS * 2);
  1.1443 -+  mpfr_init2 (b, GMP_NUMB_BITS);
  1.1444 -+  mpfr_init2 (c, GMP_NUMB_BITS);
  1.1445 -+
  1.1446 -+  /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
  1.1447 -+     with N = GMP_NUMB_BITS and k = 0 or 1.
  1.1448 -+     c = a - b should round to the same value as a. */
  1.1449 -+
  1.1450 -+  for (i = 2; i <= 3; i++)
  1.1451 -+    {
  1.1452 -+      mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
  1.1453 -+      mpfr_add_ui (a, a, 1, MPFR_RNDN);
  1.1454 -+      mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
  1.1455 -+      mpfr_set_ui (b, 1, MPFR_RNDN);
  1.1456 -+      inex = mpfr_sub (c, a, b, MPFR_RNDN);
  1.1457 -+      mpfr_set (b, a, MPFR_RNDN);
  1.1458 -+      if (! mpfr_equal_p (c, b))
  1.1459 -+        {
  1.1460 -+          printf ("Error in bug20101017 for i = %d.\n", i);
  1.1461 -+          printf ("Expected ");
  1.1462 -+          mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
  1.1463 -+          putchar ('\n');
  1.1464 -+          printf ("Got      ");
  1.1465 -+          mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
  1.1466 -+          putchar ('\n');
  1.1467 -+          exit (1);
  1.1468 -+        }
  1.1469 -+      if (inex >= 0)
  1.1470 -+        {
  1.1471 -+          printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
  1.1472 -+          printf ("Expected negative, got %d.\n", inex);
  1.1473 -+          exit (1);
  1.1474 -+        }
  1.1475 -+    }
  1.1476 -+
  1.1477 -+  mpfr_set_prec (a, 64);
  1.1478 -+  mpfr_set_prec (b, 129);
  1.1479 -+  mpfr_set_prec (c, 2);
  1.1480 -+  mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
  1.1481 -+  mpfr_set_str_binary (c, "0.10E1");
  1.1482 -+  inex = mpfr_sub (a, b, c, MPFR_RNDN);
  1.1483 -+  if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
  1.1484 -+    {
  1.1485 -+      printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
  1.1486 -+      printf ("Expected result 2^64 with inex < 0\n");
  1.1487 -+      printf ("Got "); mpfr_print_binary (a);
  1.1488 -+      printf (" with inex=%d\n", inex);
  1.1489 -+      exit (1);
  1.1490 -+    }
  1.1491 -+
  1.1492 -+  mpfr_clears (a, b, c, (mpfr_ptr) 0);
  1.1493 -+}
  1.1494 -+
  1.1495 -+/* hard test of rounding */
  1.1496 -+static void
  1.1497 -+check_rounding (void)
  1.1498 -+{
  1.1499 -+  mpfr_t a, b, c, res;
  1.1500 -+  mpfr_prec_t p;
  1.1501 -+  long k, l;
  1.1502 -+  int i;
  1.1503 -+
  1.1504 -+#define MAXKL (2 * GMP_NUMB_BITS)
  1.1505 -+  for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
  1.1506 -+    {
  1.1507 -+      mpfr_init2 (a, p);
  1.1508 -+      mpfr_init2 (res, p);
  1.1509 -+      mpfr_init2 (b, p + 1 + MAXKL);
  1.1510 -+      mpfr_init2 (c, MPFR_PREC_MIN);
  1.1511 -+
  1.1512 -+      /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
  1.1513 -+      for (k = 0; k <= MAXKL; k++)
  1.1514 -+        for (l = 0; l <= MAXKL; l++)
  1.1515 -+          {
  1.1516 -+            mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
  1.1517 -+            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  1.1518 -+            mpfr_mul_2ui (b, b, k, MPFR_RNDN);
  1.1519 -+            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  1.1520 -+            mpfr_div_2ui (b, b, k, MPFR_RNDN);
  1.1521 -+            mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
  1.1522 -+            i = mpfr_sub (a, b, c, MPFR_RNDN);
  1.1523 -+            /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
  1.1524 -+               2^p for l <= k, and 2^p+2 for l < k */
  1.1525 -+            if (l <= k)
  1.1526 -+              {
  1.1527 -+                if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
  1.1528 -+                  {
  1.1529 -+                    printf ("Wrong result in check_rounding\n");
  1.1530 -+                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  1.1531 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  1.1532 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  1.1533 -+                    printf ("Expected 2^%lu\n", p);
  1.1534 -+                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  1.1535 -+                    exit (1);
  1.1536 -+                  }
  1.1537 -+                if (i >= 0)
  1.1538 -+                  {
  1.1539 -+                    printf ("Wrong ternary value in check_rounding\n");
  1.1540 -+                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  1.1541 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  1.1542 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  1.1543 -+                    printf ("a="); mpfr_print_binary (a); puts ("");
  1.1544 -+                    printf ("Expected < 0, got %d\n", i);
  1.1545 -+                    exit (1);
  1.1546 -+                  }
  1.1547 -+              }
  1.1548 -+            else /* l < k */
  1.1549 -+              {
  1.1550 -+                mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
  1.1551 -+                mpfr_add_ui (res, res, 2, MPFR_RNDN);
  1.1552 -+                if (mpfr_cmp (a, res) != 0)
  1.1553 -+                  {
  1.1554 -+                    printf ("Wrong result in check_rounding\n");
  1.1555 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  1.1556 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  1.1557 -+                    printf ("Expected "); mpfr_print_binary (res); puts ("");
  1.1558 -+                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  1.1559 -+                    exit (1);
  1.1560 -+                  }
  1.1561 -+                if (i <= 0)
  1.1562 -+                  {
  1.1563 -+                    printf ("Wrong ternary value in check_rounding\n");
  1.1564 -+                    printf ("b="); mpfr_print_binary (b); puts ("");
  1.1565 -+                    printf ("c="); mpfr_print_binary (c); puts ("");
  1.1566 -+                    printf ("Expected > 0, got %d\n", i);
  1.1567 -+                    exit (1);
  1.1568 -+                  }
  1.1569 -+              }
  1.1570 -+          }
  1.1571 -+
  1.1572 -+      mpfr_clear (a);
  1.1573 -+      mpfr_clear (res);
  1.1574 -+      mpfr_clear (b);
  1.1575 -+      mpfr_clear (c);
  1.1576 -+    }
  1.1577 -+}
  1.1578 -+
  1.1579 - #define TEST_FUNCTION test_sub
  1.1580 - #define TWO_ARGS
  1.1581 - #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
  1.1582 -@@ -491,6 +643,8 @@
  1.1583 - 
  1.1584 -   tests_start_mpfr ();
  1.1585 - 
  1.1586 -+  bug20101017 ();
  1.1587 -+  check_rounding ();
  1.1588 -   check_diverse ();
  1.1589 -   check_inexact ();
  1.1590 -   bug_ddefour ();
  1.1591 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  1.1592 ---- mpfr-3.0.0-a/version.c	2010-10-21 20:28:38.000000000 +0000
  1.1593 -+++ mpfr-3.0.0-b/version.c	2010-10-21 20:59:32.000000000 +0000
  1.1594 -@@ -25,5 +25,5 @@
  1.1595 - const char *
  1.1596 - mpfr_get_version (void)
  1.1597 - {
  1.1598 --  return "3.0.0-p5";
  1.1599 -+  return "3.0.0-p6";
  1.1600 - }
  1.1601 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  1.1602 ---- mpfr-3.0.0-a/PATCHES	2010-10-21 21:18:26.000000000 +0000
  1.1603 -+++ mpfr-3.0.0-b/PATCHES	2010-10-21 21:18:26.000000000 +0000
  1.1604 -@@ -0,0 +1 @@
  1.1605 -+mpfr_set_ld
  1.1606 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  1.1607 ---- mpfr-3.0.0-a/VERSION	2010-10-21 20:59:32.000000000 +0000
  1.1608 -+++ mpfr-3.0.0-b/VERSION	2010-10-21 21:18:26.000000000 +0000
  1.1609 -@@ -1 +1 @@
  1.1610 --3.0.0-p6
  1.1611 -+3.0.0-p7
  1.1612 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  1.1613 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:59:32.000000000 +0000
  1.1614 -+++ mpfr-3.0.0-b/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  1.1615 -@@ -27,7 +27,7 @@
  1.1616 - #define MPFR_VERSION_MAJOR 3
  1.1617 - #define MPFR_VERSION_MINOR 0
  1.1618 - #define MPFR_VERSION_PATCHLEVEL 0
  1.1619 --#define MPFR_VERSION_STRING "3.0.0-p6"
  1.1620 -+#define MPFR_VERSION_STRING "3.0.0-p7"
  1.1621 - 
  1.1622 - /* Macros dealing with MPFR VERSION */
  1.1623 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  1.1624 -diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
  1.1625 ---- mpfr-3.0.0-a/set_ld.c	2010-06-10 11:00:14.000000000 +0000
  1.1626 -+++ mpfr-3.0.0-b/set_ld.c	2010-10-21 21:18:26.000000000 +0000
  1.1627 -@@ -102,21 +102,25 @@
  1.1628 -             {
  1.1629 -               x /= div13; /* exact */
  1.1630 -               shift_exp += 8192;
  1.1631 -+              mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
  1.1632 -             }
  1.1633 -           if (ABS (x) >= div12)
  1.1634 -             {
  1.1635 -               x /= div12; /* exact */
  1.1636 -               shift_exp += 4096;
  1.1637 -+              mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
  1.1638 -             }
  1.1639 -           if (ABS (x) >= div11)
  1.1640 -             {
  1.1641 -               x /= div11; /* exact */
  1.1642 -               shift_exp += 2048;
  1.1643 -+              mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
  1.1644 -             }
  1.1645 -           if (ABS (x) >= div10)
  1.1646 -             {
  1.1647 -               x /= div10; /* exact */
  1.1648 -               shift_exp += 1024;
  1.1649 -+              mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
  1.1650 -             }
  1.1651 -           /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
  1.1652 -              therefore we have one extra exponent reduction step */
  1.1653 -@@ -124,9 +128,10 @@
  1.1654 -             {
  1.1655 -               x /= div9; /* exact */
  1.1656 -               shift_exp += 512;
  1.1657 -+              mpfr_div_2si (t, t, 512, MPFR_RNDZ);
  1.1658 -             }
  1.1659 -         } /* Check overflow of double */
  1.1660 --      else
  1.1661 -+      else /* no overflow on double */
  1.1662 -         {
  1.1663 -           long double div9, div10, div11;
  1.1664 - 
  1.1665 -@@ -149,29 +154,34 @@
  1.1666 -                 {
  1.1667 -                   x /= div13; /* exact */
  1.1668 -                   shift_exp -= 8192;
  1.1669 -+                  mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
  1.1670 -                 }
  1.1671 -               if (ABS (x) <= div12)
  1.1672 -                 {
  1.1673 -                   x /= div12; /* exact */
  1.1674 -                   shift_exp -= 4096;
  1.1675 -+                  mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
  1.1676 -                 }
  1.1677 -               if (ABS (x) <= div11)
  1.1678 -                 {
  1.1679 -                   x /= div11; /* exact */
  1.1680 -                   shift_exp -= 2048;
  1.1681 -+                  mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
  1.1682 -                 }
  1.1683 -               if (ABS (x) <= div10)
  1.1684 -                 {
  1.1685 -                   x /= div10; /* exact */
  1.1686 -                   shift_exp -= 1024;
  1.1687 -+                  mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
  1.1688 -                 }
  1.1689 -               if (ABS(x) <= div9)
  1.1690 -                 {
  1.1691 -                   x /= div9;  /* exact */
  1.1692 -                   shift_exp -= 512;
  1.1693 -+                  mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
  1.1694 -                 }
  1.1695 -             }
  1.1696 --          else
  1.1697 -+          else /* no underflow */
  1.1698 -             {
  1.1699 -               inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
  1.1700 -               MPFR_ASSERTD (inexact == 0);
  1.1701 -diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
  1.1702 ---- mpfr-3.0.0-a/tests/tset_ld.c	2010-06-10 11:00:13.000000000 +0000
  1.1703 -+++ mpfr-3.0.0-b/tests/tset_ld.c	2010-10-21 21:18:26.000000000 +0000
  1.1704 -@@ -147,12 +147,39 @@
  1.1705 - test_fixed_bugs (void)
  1.1706 - {
  1.1707 -   mpfr_t x;
  1.1708 --  long double d;
  1.1709 -+  long double l, m;
  1.1710 - 
  1.1711 -   /* bug found by Steve Kargl (2009-03-14) */
  1.1712 -   mpfr_init2 (x, 64);
  1.1713 -   mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
  1.1714 --  d = mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  1.1715 -+  mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  1.1716 -+
  1.1717 -+  /* bug reported by Jakub Jelinek (2010-10-17)
  1.1718 -+     https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
  1.1719 -+  mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
  1.1720 -+  /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
  1.1721 -+  l = 8.215640181713713164092636634579e-276;
  1.1722 -+  mpfr_set_ld (x, l, MPFR_RNDN);
  1.1723 -+  m = mpfr_get_ld (x, MPFR_RNDN);
  1.1724 -+  if (m != l)
  1.1725 -+    {
  1.1726 -+      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  1.1727 -+      printf ("Got m=%Le instead of l\n", m);
  1.1728 -+      exit (1);
  1.1729 -+    }
  1.1730 -+
  1.1731 -+  /* another similar test which failed with extended double precision and the
  1.1732 -+     generic code for mpfr_set_ld */
  1.1733 -+  /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
  1.1734 -+  l = 4.560596445887084662336528403703e-292;
  1.1735 -+  mpfr_set_ld (x, l, MPFR_RNDN);
  1.1736 -+  m = mpfr_get_ld (x, MPFR_RNDN);
  1.1737 -+  if (m != l)
  1.1738 -+    {
  1.1739 -+      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  1.1740 -+      printf ("Got m=%Le instead of l\n", m);
  1.1741 -+      exit (1);
  1.1742 -+    }
  1.1743 - 
  1.1744 -   mpfr_clear (x);
  1.1745 - }
  1.1746 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  1.1747 ---- mpfr-3.0.0-a/version.c	2010-10-21 20:59:32.000000000 +0000
  1.1748 -+++ mpfr-3.0.0-b/version.c	2010-10-21 21:18:26.000000000 +0000
  1.1749 -@@ -25,5 +25,5 @@
  1.1750 - const char *
  1.1751 - mpfr_get_version (void)
  1.1752 - {
  1.1753 --  return "3.0.0-p6";
  1.1754 -+  return "3.0.0-p7";
  1.1755 - }
  1.1756 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  1.1757 ---- mpfr-3.0.0-a/PATCHES	2010-11-09 15:15:07.000000000 +0000
  1.1758 -+++ mpfr-3.0.0-b/PATCHES	2010-11-09 15:15:07.000000000 +0000
  1.1759 -@@ -0,0 +1 @@
  1.1760 -+macros
  1.1761 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  1.1762 ---- mpfr-3.0.0-a/VERSION	2010-10-21 21:18:26.000000000 +0000
  1.1763 -+++ mpfr-3.0.0-b/VERSION	2010-11-09 15:15:07.000000000 +0000
  1.1764 -@@ -1 +1 @@
  1.1765 --3.0.0-p7
  1.1766 -+3.0.0-p8
  1.1767 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  1.1768 ---- mpfr-3.0.0-a/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  1.1769 -+++ mpfr-3.0.0-b/mpfr.h	2010-11-09 15:15:07.000000000 +0000
  1.1770 -@@ -27,7 +27,7 @@
  1.1771 - #define MPFR_VERSION_MAJOR 3
  1.1772 - #define MPFR_VERSION_MINOR 0
  1.1773 - #define MPFR_VERSION_PATCHLEVEL 0
  1.1774 --#define MPFR_VERSION_STRING "3.0.0-p7"
  1.1775 -+#define MPFR_VERSION_STRING "3.0.0-p8"
  1.1776 - 
  1.1777 - /* Macros dealing with MPFR VERSION */
  1.1778 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  1.1779 -@@ -67,6 +67,16 @@
  1.1780 - # define _MPFR_H_HAVE_INTMAX_T 1
  1.1781 - #endif
  1.1782 - 
  1.1783 -+/* Avoid some problems with macro expansion if the user defines macros
  1.1784 -+   with the same name as keywords. By convention, identifiers and macro
  1.1785 -+   names starting with mpfr_ are reserved by MPFR. */
  1.1786 -+typedef void            mpfr_void;
  1.1787 -+typedef int             mpfr_int;
  1.1788 -+typedef unsigned int    mpfr_uint;
  1.1789 -+typedef long            mpfr_long;
  1.1790 -+typedef unsigned long   mpfr_ulong;
  1.1791 -+typedef size_t          mpfr_size_t;
  1.1792 -+
  1.1793 - /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
  1.1794 -    Warning! Changing the contents of this enum should be seen as an
  1.1795 -    interface change since the old and the new types are not compatible
  1.1796 -@@ -136,7 +146,7 @@
  1.1797 - typedef mp_exp_t     mpfr_exp_t;
  1.1798 - 
  1.1799 - /* Definition of the standard exponent limits */
  1.1800 --#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
  1.1801 -+#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
  1.1802 - #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
  1.1803 - 
  1.1804 - /* Definition of the main structure */
  1.1805 -@@ -725,13 +735,13 @@
  1.1806 -    unexpected results with future compilers and aggressive optimisations.
  1.1807 -    Why not working only with signed types, using INT_MIN and LONG_MIN? */
  1.1808 - #if __GMP_MP_SIZE_T_INT
  1.1809 --#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
  1.1810 --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
  1.1811 --#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
  1.1812 -+#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
  1.1813 -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
  1.1814 -+#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
  1.1815 - #else
  1.1816 --#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
  1.1817 --#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
  1.1818 --#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
  1.1819 -+#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
  1.1820 -+#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
  1.1821 -+#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
  1.1822 - #endif
  1.1823 - 
  1.1824 - /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
  1.1825 -@@ -760,9 +770,9 @@
  1.1826 - #define mpfr_inf_p(_x)      ((_x)->_mpfr_exp == __MPFR_EXP_INF)
  1.1827 - #define mpfr_zero_p(_x)     ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
  1.1828 - #define mpfr_regular_p(_x)  ((_x)->_mpfr_exp >  __MPFR_EXP_INF)
  1.1829 --#define mpfr_sgn(_x)                                          \
  1.1830 --  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
  1.1831 --   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
  1.1832 -+#define mpfr_sgn(_x)                                               \
  1.1833 -+  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                              \
  1.1834 -+   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
  1.1835 -    MPFR_SIGN (_x))
  1.1836 - 
  1.1837 - /* Prevent them from using as lvalues */
  1.1838 -@@ -805,7 +815,19 @@
  1.1839 -    Moreover casts to unsigned long have been added to avoid warnings in
  1.1840 -    programs that use MPFR and are compiled with -Wconversion; such casts
  1.1841 -    are OK since if X is a constant expression, then (unsigned long) X is
  1.1842 --   also a constant expression, so that the optimizations still work. */
  1.1843 -+   also a constant expression, so that the optimizations still work. The
  1.1844 -+   warnings are probably related to the following two bugs:
  1.1845 -+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
  1.1846 -+     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
  1.1847 -+   and the casts could be removed once these bugs are fixed.
  1.1848 -+   Casts shouldn't be used on the generic calls (to the ..._2exp functions),
  1.1849 -+   where implicit conversions are performed. Indeed, having at least one
  1.1850 -+   implicit conversion in the macro allows the compiler to emit diagnostics
  1.1851 -+   when normally expected, for instance in the following call:
  1.1852 -+     mpfr_set_ui (x, "foo", MPFR_RNDN);
  1.1853 -+   If this is not possible (for future macros), one of the tricks described
  1.1854 -+   on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
  1.1855 -+   be used. */
  1.1856 - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
  1.1857 - #if (__GNUC__ >= 2)
  1.1858 - #undef mpfr_cmp_ui
  1.1859 -@@ -813,45 +835,45 @@
  1.1860 -    But warning! mpfr_sgn is specified as a macro in the API, thus the macro
  1.1861 -    mustn't be used if side effects are possible, like here. */
  1.1862 - #define mpfr_cmp_ui(_f,_u)                                      \
  1.1863 --  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  1.1864 -+  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  1.1865 -    (mpfr_sgn) (_f) :                                            \
  1.1866 --   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
  1.1867 -+   mpfr_cmp_ui_2exp ((_f), (_u), 0))
  1.1868 - #undef mpfr_cmp_si
  1.1869 --#define mpfr_cmp_si(_f,_s)                              \
  1.1870 --  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
  1.1871 --   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
  1.1872 --   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
  1.1873 -+#define mpfr_cmp_si(_f,_s)                                      \
  1.1874 -+  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  1.1875 -+   mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) :          \
  1.1876 -+   mpfr_cmp_si_2exp ((_f), (_s), 0))
  1.1877 - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
  1.1878 - #undef mpfr_set_ui
  1.1879 - #define mpfr_set_ui(_f,_u,_r)                                   \
  1.1880 --  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  1.1881 -+  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  1.1882 -    __extension__ ({                                             \
  1.1883 -        mpfr_ptr _p = (_f);                                      \
  1.1884 -        _p->_mpfr_sign = 1;                                      \
  1.1885 -        _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
  1.1886 --       (void) (_r); 0; }) :                                     \
  1.1887 --   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
  1.1888 -+       (mpfr_void) (_r); 0; }) :                                \
  1.1889 -+   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
  1.1890 - #endif
  1.1891 - #undef mpfr_set_si
  1.1892 - #define mpfr_set_si(_f,_s,_r)                                   \
  1.1893 --  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
  1.1894 --   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
  1.1895 --   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
  1.1896 -+  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  1.1897 -+   mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) :    \
  1.1898 -+   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
  1.1899 - #endif
  1.1900 - #endif
  1.1901 - 
  1.1902 - /* Macro version of mpfr_stack interface for fast access */
  1.1903 --#define mpfr_custom_get_size(p) ((size_t)                            \
  1.1904 -+#define mpfr_custom_get_size(p) ((mpfr_size_t)                          \
  1.1905 -        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
  1.1906 - #define mpfr_custom_init(m,p) do {} while (0)
  1.1907 --#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
  1.1908 -+#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
  1.1909 - #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
  1.1910 - #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
  1.1911 - #define mpfr_custom_init_set(x,k,e,p,m) do {                   \
  1.1912 -   mpfr_ptr _x = (x);                                           \
  1.1913 -   mpfr_exp_t _e;                                               \
  1.1914 -   mpfr_kind_t _t;                                              \
  1.1915 --  int _s, _k;                                                  \
  1.1916 -+  mpfr_int _s, _k;                                             \
  1.1917 -   _k = (k);                                                    \
  1.1918 -   if (_k >= 0)  {                                              \
  1.1919 -     _t = (mpfr_kind_t) _k;                                     \
  1.1920 -@@ -868,11 +890,13 @@
  1.1921 -   _x->_mpfr_exp  = _e;                                         \
  1.1922 -   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
  1.1923 -  } while (0)
  1.1924 --#define mpfr_custom_get_kind(x)                                              \
  1.1925 --  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
  1.1926 --  : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
  1.1927 --  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
  1.1928 --  : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  1.1929 -+#define mpfr_custom_get_kind(x)                                         \
  1.1930 -+  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ?                                  \
  1.1931 -+    (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x)                        \
  1.1932 -+  : (x)->_mpfr_exp == __MPFR_EXP_INF ?                                  \
  1.1933 -+    (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x)                            \
  1.1934 -+  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND         \
  1.1935 -+  : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  1.1936 - 
  1.1937 - 
  1.1938 - #endif /* MPFR_USE_NO_MACRO */
  1.1939 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  1.1940 ---- mpfr-3.0.0-a/version.c	2010-10-21 21:18:26.000000000 +0000
  1.1941 -+++ mpfr-3.0.0-b/version.c	2010-11-09 15:15:07.000000000 +0000
  1.1942 -@@ -25,5 +25,5 @@
  1.1943 - const char *
  1.1944 - mpfr_get_version (void)
  1.1945 - {
  1.1946 --  return "3.0.0-p7";
  1.1947 -+  return "3.0.0-p8";
  1.1948 - }
     2.1 --- a/mpfr/stuff/mpfr-3.0.1.patch	Thu Apr 12 13:04:07 2012 +0200
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,367 +0,0 @@
     2.4 -diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
     2.5 ---- mpfr-3.0.1-a/PATCHES	2011-04-12 10:50:02.000000000 +0000
     2.6 -+++ mpfr-3.0.1-b/PATCHES	2011-04-12 10:50:02.000000000 +0000
     2.7 -@@ -0,0 +1 @@
     2.8 -+asin_exprange
     2.9 -diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
    2.10 ---- mpfr-3.0.1-a/VERSION	2011-04-04 10:19:18.000000000 +0000
    2.11 -+++ mpfr-3.0.1-b/VERSION	2011-04-12 10:50:02.000000000 +0000
    2.12 -@@ -1 +1 @@
    2.13 --3.0.1
    2.14 -+3.0.1-p1
    2.15 -diff -Naurd mpfr-3.0.1-a/asin.c mpfr-3.0.1-b/asin.c
    2.16 ---- mpfr-3.0.1-a/asin.c	2011-04-04 10:19:18.000000000 +0000
    2.17 -+++ mpfr-3.0.1-b/asin.c	2011-04-12 10:50:02.000000000 +0000
    2.18 -@@ -63,11 +63,14 @@
    2.19 - 
    2.20 -   compared = mpfr_cmp_ui (xp, 1);
    2.21 - 
    2.22 -+  MPFR_SAVE_EXPO_MARK (expo);
    2.23 -+
    2.24 -   if (MPFR_UNLIKELY (compared >= 0))
    2.25 -     {
    2.26 -       mpfr_clear (xp);
    2.27 -       if (compared > 0)                  /* asin(x) = NaN for |x| > 1 */
    2.28 -         {
    2.29 -+          MPFR_SAVE_EXPO_FREE (expo);
    2.30 -           MPFR_SET_NAN (asin);
    2.31 -           MPFR_RET_NAN;
    2.32 -         }
    2.33 -@@ -80,13 +83,11 @@
    2.34 -               inexact = -mpfr_const_pi (asin, MPFR_INVERT_RND(rnd_mode));
    2.35 -               MPFR_CHANGE_SIGN (asin);
    2.36 -             }
    2.37 --          mpfr_div_2ui (asin, asin, 1, rnd_mode); /* May underflow */
    2.38 --          return inexact;
    2.39 -+          mpfr_div_2ui (asin, asin, 1, rnd_mode);
    2.40 -         }
    2.41 -     }
    2.42 --
    2.43 --  MPFR_SAVE_EXPO_MARK (expo);
    2.44 --
    2.45 -+  else
    2.46 -+    {
    2.47 -   /* Compute exponent of 1 - ABS(x) */
    2.48 -   mpfr_ui_sub (xp, 1, xp, MPFR_RNDD);
    2.49 -   MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0);
    2.50 -@@ -115,6 +116,7 @@
    2.51 -   inexact = mpfr_set (asin, xp, rnd_mode);
    2.52 - 
    2.53 -   mpfr_clear (xp);
    2.54 -+    }
    2.55 - 
    2.56 -   MPFR_SAVE_EXPO_FREE (expo);
    2.57 -   return mpfr_check_range (asin, inexact, rnd_mode);
    2.58 -diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
    2.59 ---- mpfr-3.0.1-a/mpfr.h	2011-04-04 10:19:18.000000000 +0000
    2.60 -+++ mpfr-3.0.1-b/mpfr.h	2011-04-12 10:50:02.000000000 +0000
    2.61 -@@ -27,7 +27,7 @@
    2.62 - #define MPFR_VERSION_MAJOR 3
    2.63 - #define MPFR_VERSION_MINOR 0
    2.64 - #define MPFR_VERSION_PATCHLEVEL 1
    2.65 --#define MPFR_VERSION_STRING "3.0.1"
    2.66 -+#define MPFR_VERSION_STRING "3.0.1-p1"
    2.67 - 
    2.68 - /* Macros dealing with MPFR VERSION */
    2.69 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    2.70 -diff -Naurd mpfr-3.0.1-a/tests/tasin.c mpfr-3.0.1-b/tests/tasin.c
    2.71 ---- mpfr-3.0.1-a/tests/tasin.c	2011-04-04 10:19:17.000000000 +0000
    2.72 -+++ mpfr-3.0.1-b/tests/tasin.c	2011-04-12 10:50:02.000000000 +0000
    2.73 -@@ -219,6 +219,49 @@
    2.74 -   mpfr_clear (y);
    2.75 - }
    2.76 - 
    2.77 -+static void
    2.78 -+reduced_expo_range (void)
    2.79 -+{
    2.80 -+  mpfr_exp_t emin, emax;
    2.81 -+  mpfr_t x, y, ex_y;
    2.82 -+  int inex, ex_inex;
    2.83 -+  unsigned int flags, ex_flags;
    2.84 -+
    2.85 -+  emin = mpfr_get_emin ();
    2.86 -+  emax = mpfr_get_emax ();
    2.87 -+
    2.88 -+  mpfr_inits2 (4, x, y, ex_y, (mpfr_ptr) 0);
    2.89 -+  mpfr_set_str (x, "-0.1e1", 2, MPFR_RNDN);
    2.90 -+
    2.91 -+  mpfr_set_emin (1);
    2.92 -+  mpfr_set_emax (1);
    2.93 -+  mpfr_clear_flags ();
    2.94 -+  inex = mpfr_asin (y, x, MPFR_RNDA);
    2.95 -+  flags = __gmpfr_flags;
    2.96 -+  mpfr_set_emin (emin);
    2.97 -+  mpfr_set_emax (emax);
    2.98 -+
    2.99 -+  mpfr_set_str (ex_y, "-0.1101e1", 2, MPFR_RNDN);
   2.100 -+  ex_inex = -1;
   2.101 -+  ex_flags = MPFR_FLAGS_INEXACT;
   2.102 -+
   2.103 -+  if (SIGN (inex) != ex_inex || flags != ex_flags ||
   2.104 -+      ! mpfr_equal_p (y, ex_y))
   2.105 -+    {
   2.106 -+      printf ("Error in reduced_expo_range\non x = ");
   2.107 -+      mpfr_dump (x);
   2.108 -+      printf ("Expected y = ");
   2.109 -+      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
   2.110 -+      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
   2.111 -+      printf ("Got      y = ");
   2.112 -+      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
   2.113 -+      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
   2.114 -+      exit (1);
   2.115 -+    }
   2.116 -+
   2.117 -+  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
   2.118 -+}
   2.119 -+
   2.120 - int
   2.121 - main (void)
   2.122 - {
   2.123 -@@ -226,6 +269,7 @@
   2.124 - 
   2.125 -   special ();
   2.126 -   special_overflow ();
   2.127 -+  reduced_expo_range ();
   2.128 - 
   2.129 -   test_generic (2, 100, 15);
   2.130 - 
   2.131 -diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   2.132 ---- mpfr-3.0.1-a/version.c	2011-04-04 10:19:18.000000000 +0000
   2.133 -+++ mpfr-3.0.1-b/version.c	2011-04-12 10:50:02.000000000 +0000
   2.134 -@@ -25,5 +25,5 @@
   2.135 - const char *
   2.136 - mpfr_get_version (void)
   2.137 - {
   2.138 --  return "3.0.1";
   2.139 -+  return "3.0.1-p1";
   2.140 - }
   2.141 -diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   2.142 ---- mpfr-3.0.1-a/PATCHES	2011-05-04 11:18:33.000000000 +0000
   2.143 -+++ mpfr-3.0.1-b/PATCHES	2011-05-04 11:18:33.000000000 +0000
   2.144 -@@ -0,0 +1 @@
   2.145 -+rec_sqrt-carry
   2.146 -diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   2.147 ---- mpfr-3.0.1-a/VERSION	2011-04-12 10:50:02.000000000 +0000
   2.148 -+++ mpfr-3.0.1-b/VERSION	2011-05-04 11:18:33.000000000 +0000
   2.149 -@@ -1 +1 @@
   2.150 --3.0.1-p1
   2.151 -+3.0.1-p2
   2.152 -diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   2.153 ---- mpfr-3.0.1-a/mpfr.h	2011-04-12 10:50:02.000000000 +0000
   2.154 -+++ mpfr-3.0.1-b/mpfr.h	2011-05-04 11:18:33.000000000 +0000
   2.155 -@@ -27,7 +27,7 @@
   2.156 - #define MPFR_VERSION_MAJOR 3
   2.157 - #define MPFR_VERSION_MINOR 0
   2.158 - #define MPFR_VERSION_PATCHLEVEL 1
   2.159 --#define MPFR_VERSION_STRING "3.0.1-p1"
   2.160 -+#define MPFR_VERSION_STRING "3.0.1-p2"
   2.161 - 
   2.162 - /* Macros dealing with MPFR VERSION */
   2.163 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.164 -diff -Naurd mpfr-3.0.1-a/rec_sqrt.c mpfr-3.0.1-b/rec_sqrt.c
   2.165 ---- mpfr-3.0.1-a/rec_sqrt.c	2011-04-04 10:19:18.000000000 +0000
   2.166 -+++ mpfr-3.0.1-b/rec_sqrt.c	2011-05-04 11:18:33.000000000 +0000
   2.167 -@@ -375,20 +375,37 @@
   2.168 -       MPFR_ASSERTD(un == ln + 1 || un == ln + 2);
   2.169 -       /* the high un-ln limbs of u will overlap the low part of {x+ln,xn},
   2.170 -          we need to add or subtract the overlapping part {u + ln, un - ln} */
   2.171 -+      /* Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1
   2.172 -+         below (with size = th) mustn't be used. In such a case, the limb
   2.173 -+         (carry) will be 0, so that this is semantically a no-op, but if
   2.174 -+         mpn_add_1 and mpn_sub_1 are used, GMP (currently) still does a
   2.175 -+         non-atomic read/write in a place that is not always allocated,
   2.176 -+         with the possible consequences: a crash if the corresponding
   2.177 -+         address is not mapped, or (rather unlikely) memory corruption
   2.178 -+         if another process/thread writes at the same place; things may
   2.179 -+         be worse with future GMP versions. Hence the tests carry != 0. */
   2.180 -       if (neg == 0)
   2.181 -         {
   2.182 -           if (ln > 0)
   2.183 -             MPN_COPY (x, u, ln);
   2.184 -           cy = mpn_add (x + ln, x + ln, xn, u + ln, un - ln);
   2.185 -           /* add cu at x+un */
   2.186 --          cy += mpn_add_1 (x + un, x + un, th, cu);
   2.187 -+          if (cu != 0)
   2.188 -+            {
   2.189 -+              MPFR_ASSERTD (th != 0);
   2.190 -+              cy += mpn_add_1 (x + un, x + un, th, cu);
   2.191 -+            }
   2.192 -         }
   2.193 -       else /* negative case */
   2.194 -         {
   2.195 -           /* subtract {u+ln, un-ln} from {x+ln,un} */
   2.196 -           cy = mpn_sub (x + ln, x + ln, xn, u + ln, un - ln);
   2.197 -           /* carry cy is at x+un, like cu */
   2.198 --          cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
   2.199 -+          if (cy + cu != 0)
   2.200 -+            {
   2.201 -+              MPFR_ASSERTD (th != 0);
   2.202 -+              cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
   2.203 -+            }
   2.204 -           /* cy cannot be zero, since the most significant bit of Xh is 1,
   2.205 -              and the correction is bounded by 2^{-h+3} */
   2.206 -           MPFR_ASSERTD(cy == 0);
   2.207 -diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   2.208 ---- mpfr-3.0.1-a/version.c	2011-04-12 10:50:02.000000000 +0000
   2.209 -+++ mpfr-3.0.1-b/version.c	2011-05-04 11:18:33.000000000 +0000
   2.210 -@@ -25,5 +25,5 @@
   2.211 - const char *
   2.212 - mpfr_get_version (void)
   2.213 - {
   2.214 --  return "3.0.1-p1";
   2.215 -+  return "3.0.1-p2";
   2.216 - }
   2.217 -diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   2.218 ---- mpfr-3.0.1-a/PATCHES	2011-05-05 00:00:35.000000000 +0000
   2.219 -+++ mpfr-3.0.1-b/PATCHES	2011-05-05 00:00:35.000000000 +0000
   2.220 -@@ -0,0 +1 @@
   2.221 -+atan-expo-range
   2.222 -diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   2.223 ---- mpfr-3.0.1-a/VERSION	2011-05-04 11:18:33.000000000 +0000
   2.224 -+++ mpfr-3.0.1-b/VERSION	2011-05-05 00:00:35.000000000 +0000
   2.225 -@@ -1 +1 @@
   2.226 --3.0.1-p2
   2.227 -+3.0.1-p3
   2.228 -diff -Naurd mpfr-3.0.1-a/atan.c mpfr-3.0.1-b/atan.c
   2.229 ---- mpfr-3.0.1-a/atan.c	2011-04-04 10:19:18.000000000 +0000
   2.230 -+++ mpfr-3.0.1-b/atan.c	2011-05-05 00:00:35.000000000 +0000
   2.231 -@@ -431,5 +431,5 @@
   2.232 -   MPFR_GROUP_CLEAR (group);
   2.233 - 
   2.234 -   MPFR_SAVE_EXPO_FREE (expo);
   2.235 --  return mpfr_check_range (arctgt, inexact, rnd_mode);
   2.236 -+  return mpfr_check_range (atan, inexact, rnd_mode);
   2.237 - }
   2.238 -diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   2.239 ---- mpfr-3.0.1-a/mpfr.h	2011-05-04 11:18:33.000000000 +0000
   2.240 -+++ mpfr-3.0.1-b/mpfr.h	2011-05-05 00:00:35.000000000 +0000
   2.241 -@@ -27,7 +27,7 @@
   2.242 - #define MPFR_VERSION_MAJOR 3
   2.243 - #define MPFR_VERSION_MINOR 0
   2.244 - #define MPFR_VERSION_PATCHLEVEL 1
   2.245 --#define MPFR_VERSION_STRING "3.0.1-p2"
   2.246 -+#define MPFR_VERSION_STRING "3.0.1-p3"
   2.247 - 
   2.248 - /* Macros dealing with MPFR VERSION */
   2.249 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.250 -diff -Naurd mpfr-3.0.1-a/tests/tatan.c mpfr-3.0.1-b/tests/tatan.c
   2.251 ---- mpfr-3.0.1-a/tests/tatan.c	2011-04-04 10:19:17.000000000 +0000
   2.252 -+++ mpfr-3.0.1-b/tests/tatan.c	2011-05-05 00:00:35.000000000 +0000
   2.253 -@@ -535,6 +535,52 @@
   2.254 -   mpfr_clears (a, x, y, (mpfr_ptr) 0);
   2.255 - }
   2.256 - 
   2.257 -+/* http://websympa.loria.fr/wwsympa/arc/mpfr/2011-05/msg00008.html
   2.258 -+ * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
   2.259 -+ */
   2.260 -+static void
   2.261 -+reduced_expo_range (void)
   2.262 -+{
   2.263 -+  mpfr_exp_t emin, emax;
   2.264 -+  mpfr_t x, y, ex_y;
   2.265 -+  int inex, ex_inex;
   2.266 -+  unsigned int flags, ex_flags;
   2.267 -+
   2.268 -+  emin = mpfr_get_emin ();
   2.269 -+  emax = mpfr_get_emax ();
   2.270 -+
   2.271 -+  mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
   2.272 -+  mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);
   2.273 -+
   2.274 -+  mpfr_set_emin (-5);
   2.275 -+  mpfr_set_emax (-5);
   2.276 -+  mpfr_clear_flags ();
   2.277 -+  inex = mpfr_atan (y, x, MPFR_RNDN);
   2.278 -+  flags = __gmpfr_flags;
   2.279 -+  mpfr_set_emin (emin);
   2.280 -+  mpfr_set_emax (emax);
   2.281 -+
   2.282 -+  mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
   2.283 -+  ex_inex = 1;
   2.284 -+  ex_flags = MPFR_FLAGS_INEXACT;
   2.285 -+
   2.286 -+  if (SIGN (inex) != ex_inex || flags != ex_flags ||
   2.287 -+      ! mpfr_equal_p (y, ex_y))
   2.288 -+    {
   2.289 -+      printf ("Error in reduced_expo_range\non x = ");
   2.290 -+      mpfr_dump (x);
   2.291 -+      printf ("Expected y = ");
   2.292 -+      mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
   2.293 -+      printf ("\n         inex = %d, flags = %u\n", ex_inex, ex_flags);
   2.294 -+      printf ("Got      y = ");
   2.295 -+      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
   2.296 -+      printf ("\n         inex = %d, flags = %u\n", SIGN (inex), flags);
   2.297 -+      exit (1);
   2.298 -+    }
   2.299 -+
   2.300 -+  mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
   2.301 -+}
   2.302 -+
   2.303 - int
   2.304 - main (int argc, char *argv[])
   2.305 - {
   2.306 -@@ -546,6 +592,7 @@
   2.307 -   smallvals_atan2 ();
   2.308 -   atan2_bug_20071003 ();
   2.309 -   atan2_different_prec ();
   2.310 -+  reduced_expo_range ();
   2.311 - 
   2.312 -   test_generic_atan  (2, 200, 17);
   2.313 -   test_generic_atan2 (2, 200, 17);
   2.314 -diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   2.315 ---- mpfr-3.0.1-a/version.c	2011-05-04 11:18:33.000000000 +0000
   2.316 -+++ mpfr-3.0.1-b/version.c	2011-05-05 00:00:35.000000000 +0000
   2.317 -@@ -25,5 +25,5 @@
   2.318 - const char *
   2.319 - mpfr_get_version (void)
   2.320 - {
   2.321 --  return "3.0.1-p2";
   2.322 -+  return "3.0.1-p3";
   2.323 - }
   2.324 -diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
   2.325 ---- mpfr-3.0.1-a/PATCHES	2011-05-09 14:48:24.000000000 +0000
   2.326 -+++ mpfr-3.0.1-b/PATCHES	2011-05-09 14:48:24.000000000 +0000
   2.327 -@@ -0,0 +1 @@
   2.328 -+texp-zero
   2.329 -diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
   2.330 ---- mpfr-3.0.1-a/VERSION	2011-05-05 00:00:35.000000000 +0000
   2.331 -+++ mpfr-3.0.1-b/VERSION	2011-05-09 14:48:24.000000000 +0000
   2.332 -@@ -1 +1 @@
   2.333 --3.0.1-p3
   2.334 -+3.0.1-p4
   2.335 -diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
   2.336 ---- mpfr-3.0.1-a/mpfr.h	2011-05-05 00:00:35.000000000 +0000
   2.337 -+++ mpfr-3.0.1-b/mpfr.h	2011-05-09 14:48:24.000000000 +0000
   2.338 -@@ -27,7 +27,7 @@
   2.339 - #define MPFR_VERSION_MAJOR 3
   2.340 - #define MPFR_VERSION_MINOR 0
   2.341 - #define MPFR_VERSION_PATCHLEVEL 1
   2.342 --#define MPFR_VERSION_STRING "3.0.1-p3"
   2.343 -+#define MPFR_VERSION_STRING "3.0.1-p4"
   2.344 - 
   2.345 - /* Macros dealing with MPFR VERSION */
   2.346 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   2.347 -diff -Naurd mpfr-3.0.1-a/tests/texp.c mpfr-3.0.1-b/tests/texp.c
   2.348 ---- mpfr-3.0.1-a/tests/texp.c	2011-04-04 10:19:17.000000000 +0000
   2.349 -+++ mpfr-3.0.1-b/tests/texp.c	2011-05-09 14:48:24.000000000 +0000
   2.350 -@@ -170,7 +170,9 @@
   2.351 -       mpfr_set_prec (x, prec);
   2.352 -       mpfr_set_prec (y, prec);
   2.353 -       mpfr_set_prec (z, prec);
   2.354 --      mpfr_urandomb (x, RANDS);
   2.355 -+      do
   2.356 -+        mpfr_urandomb (x, RANDS);
   2.357 -+      while (MPFR_IS_ZERO (x));  /* 0 is handled by mpfr_exp only */
   2.358 -       rnd = RND_RAND ();
   2.359 -       mpfr_exp_2 (y, x, rnd);
   2.360 -       mpfr_exp_3 (z, x, rnd);
   2.361 -diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
   2.362 ---- mpfr-3.0.1-a/version.c	2011-05-05 00:00:35.000000000 +0000
   2.363 -+++ mpfr-3.0.1-b/version.c	2011-05-09 14:48:24.000000000 +0000
   2.364 -@@ -25,5 +25,5 @@
   2.365 - const char *
   2.366 - mpfr_get_version (void)
   2.367 - {
   2.368 --  return "3.0.1-p3";
   2.369 -+  return "3.0.1-p4";
   2.370 - }
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/mpfr/stuff/mpfr-3.1.0.patch	Thu Apr 12 14:35:51 2012 +0200
     3.3 @@ -0,0 +1,473 @@
     3.4 +Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
     3.5 +Date:                    2011-12-22
     3.6 +Initial Package Version: 3.1.0
     3.7 +Upstream Status:         Already in upstream patch repo
     3.8 +Origin:                  Upstream
     3.9 +Description:             This patch contains patches for several bugs in MPFR,
    3.10 +                         the main one being a rounding related error with the
    3.11 +                         mpfr_*printf functions.
    3.12 +
    3.13 +diff -Naur mpfr-3.1.0.orig/PATCHES mpfr-3.1.0/PATCHES
    3.14 +--- mpfr-3.1.0.orig/PATCHES	2011-10-03 08:17:15.000000000 +0000
    3.15 ++++ mpfr-3.1.0/PATCHES	2011-12-22 11:08:42.188819413 +0000
    3.16 +@@ -0,0 +1,4 @@
    3.17 ++gmp41compat
    3.18 ++vasprintf
    3.19 ++lib-search-path
    3.20 ++mpfr_unlikely
    3.21 +diff -Naur mpfr-3.1.0.orig/VERSION mpfr-3.1.0/VERSION
    3.22 +--- mpfr-3.1.0.orig/VERSION	2011-10-03 08:17:15.000000000 +0000
    3.23 ++++ mpfr-3.1.0/VERSION	2011-11-28 12:22:52.000000000 +0000
    3.24 +@@ -1 +1 @@
    3.25 +-3.1.0
    3.26 ++3.1.0-p4
    3.27 +diff -Naur mpfr-3.1.0.orig/doc/mpfr.info mpfr-3.1.0/doc/mpfr.info
    3.28 +--- mpfr-3.1.0.orig/doc/mpfr.info	2011-10-03 09:43:04.000000000 +0000
    3.29 ++++ mpfr-3.1.0/doc/mpfr.info	2011-11-28 12:22:52.000000000 +0000
    3.30 +@@ -2994,11 +2994,12 @@
    3.31 + 
    3.32 +    * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1.  Their
    3.33 +      behavior no longer depends on the platform (assuming this is also
    3.34 +-     true for GMP's random generator).  As a consequence, the returned
    3.35 +-     values can be different between MPFR 3.1 and previous MPFR
    3.36 +-     versions.  Note: as the reproducibility of these functions was not
    3.37 +-     specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ regarded
    3.38 +-     as backward incompatible with previous versions.
    3.39 ++     true for GMP's random generator, which is not the case between GMP
    3.40 ++     4.1 and 4.2 if `gmp_randinit_default' is used).  As a consequence,
    3.41 ++     the returned values can be different between MPFR 3.1 and previous
    3.42 ++     MPFR versions.  Note: as the reproducibility of these functions
    3.43 ++     was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_
    3.44 ++     regarded as backward incompatible with previous versions.
    3.45 + 
    3.46 + 
    3.47 + 
    3.48 +@@ -4239,13 +4240,13 @@
    3.49 + Node: Type and Macro Changes129308
    3.50 + Node: Added Functions132029
    3.51 + Node: Changed Functions134972
    3.52 +-Node: Removed Functions139167
    3.53 +-Node: Other Changes139579
    3.54 +-Node: Contributors141108
    3.55 +-Node: References143574
    3.56 +-Node: GNU Free Documentation License145315
    3.57 +-Node: Concept Index167758
    3.58 +-Node: Function and Type Index173677
    3.59 ++Node: Removed Functions139253
    3.60 ++Node: Other Changes139665
    3.61 ++Node: Contributors141194
    3.62 ++Node: References143660
    3.63 ++Node: GNU Free Documentation License145401
    3.64 ++Node: Concept Index167844
    3.65 ++Node: Function and Type Index173763
    3.66 + 
    3.67 + End Tag Table
    3.68 + 
    3.69 +diff -Naur mpfr-3.1.0.orig/doc/mpfr.texi mpfr-3.1.0/doc/mpfr.texi
    3.70 +--- mpfr-3.1.0.orig/doc/mpfr.texi	2011-10-03 08:17:14.000000000 +0000
    3.71 ++++ mpfr-3.1.0/doc/mpfr.texi	2011-11-28 12:22:52.000000000 +0000
    3.72 +@@ -3466,8 +3466,9 @@
    3.73 + a lack of specification.
    3.74 + 
    3.75 + @item @code{mpfr_urandom} and @code{mpfr_urandomb} changed in MPFR 3.1.
    3.76 +-Their behavior no longer depends on the platform (assuming this is also
    3.77 +-true for GMP's random generator).  As a consequence, the returned values
    3.78 ++Their behavior no longer depends on the platform (assuming this is also true
    3.79 ++for GMP's random generator, which is not the case between GMP 4.1 and 4.2 if
    3.80 ++@code{gmp_randinit_default} is used).  As a consequence, the returned values
    3.81 + can be different between MPFR 3.1 and previous MPFR versions.
    3.82 + Note: as the reproducibility of these functions was not specified
    3.83 + before MPFR 3.1, the MPFR 3.1 behavior is @emph{not} regarded as
    3.84 +diff -Naur mpfr-3.1.0.orig/src/mpfr-impl.h mpfr-3.1.0/src/mpfr-impl.h
    3.85 +--- mpfr-3.1.0.orig/src/mpfr-impl.h	2011-10-03 08:17:09.000000000 +0000
    3.86 ++++ mpfr-3.1.0/src/mpfr-impl.h	2011-10-05 21:39:57.000000000 +0000
    3.87 +@@ -988,10 +988,11 @@
    3.88 +  ******************************************************/
    3.89 + 
    3.90 + /* Theses macros help the compiler to determine if a test is
    3.91 +- * likely or unlikely. */
    3.92 ++   likely or unlikely. The !! is necessary in case x is larger
    3.93 ++   than a long. */
    3.94 + #if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
    3.95 + # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
    3.96 +-# define MPFR_UNLIKELY(x) (__builtin_expect((x),0))
    3.97 ++# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0))
    3.98 + #else
    3.99 + # define MPFR_LIKELY(x) (x)
   3.100 + # define MPFR_UNLIKELY(x) (x)
   3.101 +diff -Naur mpfr-3.1.0.orig/src/mpfr.h mpfr-3.1.0/src/mpfr.h
   3.102 +--- mpfr-3.1.0.orig/src/mpfr.h	2011-10-03 08:17:09.000000000 +0000
   3.103 ++++ mpfr-3.1.0/src/mpfr.h	2011-11-28 12:22:52.000000000 +0000
   3.104 +@@ -27,7 +27,7 @@
   3.105 + #define MPFR_VERSION_MAJOR 3
   3.106 + #define MPFR_VERSION_MINOR 1
   3.107 + #define MPFR_VERSION_PATCHLEVEL 0
   3.108 +-#define MPFR_VERSION_STRING "3.1.0"
   3.109 ++#define MPFR_VERSION_STRING "3.1.0-p4"
   3.110 + 
   3.111 + /* Macros dealing with MPFR VERSION */
   3.112 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.113 +diff -Naur mpfr-3.1.0.orig/src/vasprintf.c mpfr-3.1.0/src/vasprintf.c
   3.114 +--- mpfr-3.1.0.orig/src/vasprintf.c	2011-10-03 08:17:09.000000000 +0000
   3.115 ++++ mpfr-3.1.0/src/vasprintf.c	2011-11-03 15:15:11.000000000 +0000
   3.116 +@@ -1178,7 +1178,7 @@
   3.117 +   mpfr_exp_t exp;
   3.118 +   char * str;
   3.119 +   const int spec_g = (spec.spec == 'g' || spec.spec == 'G');
   3.120 +-  const int keep_trailing_zeros = spec_g && spec.alt;
   3.121 ++  const int keep_trailing_zeros = !spec_g || spec.alt;
   3.122 + 
   3.123 +   /* WARNING: an empty precision field is forbidden (it means precision = 6
   3.124 +      and it should have been changed to 6 before the function call) */
   3.125 +@@ -1356,7 +1356,7 @@
   3.126 +   else
   3.127 +     /* 1 <= |p| */
   3.128 +     {
   3.129 +-      size_t nsd;  /* Number of significant digits */
   3.130 ++      size_t str_len;
   3.131 + 
   3.132 +       /* Determine the position of the most significant decimal digit. */
   3.133 +       exp = floor_log10 (p);
   3.134 +@@ -1365,12 +1365,10 @@
   3.135 +         /* P is too large to print all its integral part digits */
   3.136 +         return -1;
   3.137 + 
   3.138 +-      np->ip_size = exp + 1;
   3.139 +-
   3.140 +-      nsd = spec.prec + np->ip_size;
   3.141 +       if (dec_info == NULL)
   3.142 +-        {
   3.143 +-          str = mpfr_get_str (NULL, &exp, 10, nsd, p, spec.rnd_mode);
   3.144 ++        { /* this case occurs with mpfr_printf ("%.0RUf", x) with x=9.5 */
   3.145 ++          str =
   3.146 ++            mpfr_get_str (NULL, &exp, 10, spec.prec+exp+1, p, spec.rnd_mode);
   3.147 +           register_string (np->sl, str);
   3.148 +         }
   3.149 +       else
   3.150 +@@ -1379,81 +1377,60 @@
   3.151 +           str = dec_info->str;
   3.152 +         }
   3.153 +       np->ip_ptr = MPFR_IS_NEG (p) ? ++str : str; /* skip sign */
   3.154 ++      str_len = strlen (str);
   3.155 ++
   3.156 ++      /* integral part */
   3.157 ++      if (exp > str_len)
   3.158 ++        /* mpfr_get_str gives no trailing zero when p is rounded up to the next
   3.159 ++           power of 10 (p integer, so no fractional part) */
   3.160 ++        {
   3.161 ++          np->ip_trailing_zeros = exp - str_len;
   3.162 ++          np->ip_size = str_len;
   3.163 ++        }
   3.164 ++      else
   3.165 ++        np->ip_size = exp;
   3.166 + 
   3.167 +       if (spec.group)
   3.168 +         /* thousands separator in integral part */
   3.169 +         np->thousands_sep = MPFR_THOUSANDS_SEPARATOR;
   3.170 + 
   3.171 +-      if (nsd == 0 || (spec_g && !spec.alt))
   3.172 +-        /* compute how much non-zero digits in integral and fractional
   3.173 +-           parts */
   3.174 ++      /* fractional part */
   3.175 ++      str += np->ip_size;
   3.176 ++      str_len -= np->ip_size;
   3.177 ++      if (!keep_trailing_zeros)
   3.178 ++        /* remove trailing zeros, if any */
   3.179 +         {
   3.180 +-          size_t str_len;
   3.181 +-          str_len = strlen (str); /* note: the sign has been skipped */
   3.182 +-
   3.183 +-          if (exp > str_len)
   3.184 +-            /* mpfr_get_str doesn't give the trailing zeros when p is a
   3.185 +-               multiple of 10 (p integer, so no fractional part) */
   3.186 ++          char *ptr = str + str_len - 1; /* pointer to the last digit of
   3.187 ++                                            str */
   3.188 ++          while ((*ptr == '0') && (str_len != 0))
   3.189 +             {
   3.190 +-              np->ip_trailing_zeros = exp - str_len;
   3.191 +-              np->ip_size = str_len;
   3.192 +-              if (spec.alt)
   3.193 +-                np->point = MPFR_DECIMAL_POINT;
   3.194 +-            }
   3.195 +-          else
   3.196 +-            /* str may contain some digits which are in fractional part */
   3.197 +-            {
   3.198 +-              char *ptr;
   3.199 +-
   3.200 +-              ptr = str + str_len - 1; /* points to the end of str */
   3.201 +-              str_len -= np->ip_size;  /* number of digits in fractional
   3.202 +-                                          part */
   3.203 +-
   3.204 +-              if (!keep_trailing_zeros)
   3.205 +-                /* remove trailing zeros, if any */
   3.206 +-                {
   3.207 +-                  while ((*ptr == '0') && (str_len != 0))
   3.208 +-                    {
   3.209 +-                      --ptr;
   3.210 +-                      --str_len;
   3.211 +-                    }
   3.212 +-                }
   3.213 +-
   3.214 +-              if (str_len > INT_MAX)
   3.215 +-                /* too many digits in fractional part */
   3.216 +-                return -1;
   3.217 +-
   3.218 +-              if (str_len != 0)
   3.219 +-                /* some digits in fractional part */
   3.220 +-                {
   3.221 +-                  np->point = MPFR_DECIMAL_POINT;
   3.222 +-                  np->fp_ptr = str + np->ip_size;
   3.223 +-                  np->fp_size = str_len;
   3.224 +-                }
   3.225 ++              --ptr;
   3.226 ++              --str_len;
   3.227 +             }
   3.228 +         }
   3.229 +-      else
   3.230 +-        /* spec.prec digits in fractional part */
   3.231 +-        {
   3.232 +-          if (np->ip_size == exp - 1)
   3.233 +-            /* the absolute value of the number has been rounded up to a power
   3.234 +-               of ten.
   3.235 +-               Insert an additional zero in integral part and put the rest of
   3.236 +-               them in fractional part. */
   3.237 +-            np->ip_trailing_zeros = 1;
   3.238 + 
   3.239 +-          if (spec.prec != 0)
   3.240 +-            {
   3.241 +-              MPFR_ASSERTD (np->ip_size + np->ip_trailing_zeros == exp);
   3.242 +-              MPFR_ASSERTD (np->ip_size + spec.prec == nsd);
   3.243 ++      if (str_len > 0)
   3.244 ++        /* some nonzero digits in fractional part */
   3.245 ++        {
   3.246 ++          if (str_len > INT_MAX)
   3.247 ++            /* too many digits in fractional part */
   3.248 ++            return -1;
   3.249 ++
   3.250 ++          np->point = MPFR_DECIMAL_POINT;
   3.251 ++          np->fp_ptr = str;
   3.252 ++          np->fp_size = str_len;
   3.253 ++        }
   3.254 + 
   3.255 +-              np->point = MPFR_DECIMAL_POINT;
   3.256 +-              np->fp_ptr = str + np->ip_size;
   3.257 +-              np->fp_size = spec.prec;
   3.258 +-            }
   3.259 +-          else if (spec.alt)
   3.260 +-            np->point = MPFR_DECIMAL_POINT;
   3.261 ++      if (keep_trailing_zeros && str_len < spec.prec)
   3.262 ++        /* add missing trailing zeros */
   3.263 ++        {
   3.264 ++          np->point = MPFR_DECIMAL_POINT;
   3.265 ++          np->fp_trailing_zeros = spec.prec - np->fp_size;
   3.266 +         }
   3.267 ++
   3.268 ++      if (spec.alt)
   3.269 ++        /* add decimal point even if no digits follow it */
   3.270 ++        np->point = MPFR_DECIMAL_POINT;
   3.271 +     }
   3.272 + 
   3.273 +   return 0;
   3.274 +diff -Naur mpfr-3.1.0.orig/src/version.c mpfr-3.1.0/src/version.c
   3.275 +--- mpfr-3.1.0.orig/src/version.c	2011-10-03 08:17:09.000000000 +0000
   3.276 ++++ mpfr-3.1.0/src/version.c	2011-11-28 12:22:52.000000000 +0000
   3.277 +@@ -25,5 +25,5 @@
   3.278 + const char *
   3.279 + mpfr_get_version (void)
   3.280 + {
   3.281 +-  return "3.1.0";
   3.282 ++  return "3.1.0-p4";
   3.283 + }
   3.284 +diff -Naur mpfr-3.1.0.orig/tests/Makefile.am mpfr-3.1.0/tests/Makefile.am
   3.285 +--- mpfr-3.1.0.orig/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   3.286 ++++ mpfr-3.1.0/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   3.287 +@@ -65,8 +65,24 @@
   3.288 + TESTS = $(check_PROGRAMS)
   3.289 + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   3.290 + 
   3.291 +-# Option to prevent libtool from generating wrapper scripts for the tests.
   3.292 ++# The -no-install option prevents libtool from generating wrapper scripts
   3.293 ++# for the tests.
   3.294 + # This is useful to easily run the test scripts under valgrind or gdb.
   3.295 + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   3.296 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   3.297 +-AM_LDFLAGS = -no-install
   3.298 ++#
   3.299 ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   3.300 ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   3.301 ++# library is already installed in the corresponding lib directory: its
   3.302 ++# purpose is to make sure that the local .libs comes first in the library
   3.303 ++# search path (otherwise the tests are linked against the old MPFR library
   3.304 ++# by the LINK command -- see the generated Makefile). See:
   3.305 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   3.306 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   3.307 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   3.308 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   3.309 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   3.310 ++# and
   3.311 ++#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   3.312 ++#
   3.313 ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   3.314 +diff -Naur mpfr-3.1.0.orig/tests/Makefile.in mpfr-3.1.0/tests/Makefile.in
   3.315 +--- mpfr-3.1.0.orig/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   3.316 ++++ mpfr-3.1.0/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   3.317 +@@ -1124,11 +1124,27 @@
   3.318 + TESTS = $(check_PROGRAMS)
   3.319 + TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   3.320 + 
   3.321 +-# Option to prevent libtool from generating wrapper scripts for the tests.
   3.322 ++# The -no-install option prevents libtool from generating wrapper scripts
   3.323 ++# for the tests.
   3.324 + # This is useful to easily run the test scripts under valgrind or gdb.
   3.325 + # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   3.326 + # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   3.327 +-AM_LDFLAGS = -no-install
   3.328 ++#
   3.329 ++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   3.330 ++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   3.331 ++# library is already installed in the corresponding lib directory: its
   3.332 ++# purpose is to make sure that the local .libs comes first in the library
   3.333 ++# search path (otherwise the tests are linked against the old MPFR library
   3.334 ++# by the LINK command -- see the generated Makefile). See:
   3.335 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   3.336 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   3.337 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   3.338 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   3.339 ++#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   3.340 ++# and
   3.341 ++#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   3.342 ++#
   3.343 ++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   3.344 + all: all-am
   3.345 + 
   3.346 + .SUFFIXES:
   3.347 +diff -Naur mpfr-3.1.0.orig/tests/trandom.c mpfr-3.1.0/tests/trandom.c
   3.348 +--- mpfr-3.1.0.orig/tests/trandom.c	2011-10-03 08:17:14.000000000 +0000
   3.349 ++++ mpfr-3.1.0/tests/trandom.c	2011-11-28 12:22:52.000000000 +0000
   3.350 +@@ -114,21 +114,29 @@
   3.351 +   mpfr_t x;
   3.352 +   gmp_randstate_t s;
   3.353 + 
   3.354 ++#if __MPFR_GMP(4,2,0)
   3.355 ++# define C1 "0.895943"
   3.356 ++# define C2 "0.848824"
   3.357 ++#else
   3.358 ++# define C1 "0.479652"
   3.359 ++# define C2 "0.648529"
   3.360 ++#endif
   3.361 ++
   3.362 +   gmp_randinit_default (s);
   3.363 +   gmp_randseed_ui (s, 42);
   3.364 +   mpfr_init2 (x, 17);
   3.365 +   mpfr_urandomb (x, s);
   3.366 +-  if (mpfr_cmp_str1 (x, "0.895943") != 0)
   3.367 ++  if (mpfr_cmp_str1 (x, C1) != 0)
   3.368 +     {
   3.369 +-      printf ("Error in bug20100914, expected 0.895943, got ");
   3.370 ++      printf ("Error in bug20100914, expected " C1 ", got ");
   3.371 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.372 +       printf ("\n");
   3.373 +       exit (1);
   3.374 +     }
   3.375 +   mpfr_urandomb (x, s);
   3.376 +-  if (mpfr_cmp_str1 (x, "0.848824") != 0)
   3.377 ++  if (mpfr_cmp_str1 (x, C2) != 0)
   3.378 +     {
   3.379 +-      printf ("Error in bug20100914, expected 0.848824, got ");
   3.380 ++      printf ("Error in bug20100914, expected " C2 ", got ");
   3.381 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.382 +       printf ("\n");
   3.383 +       exit (1);
   3.384 +diff -Naur mpfr-3.1.0.orig/tests/tsprintf.c mpfr-3.1.0/tests/tsprintf.c
   3.385 +--- mpfr-3.1.0.orig/tests/tsprintf.c	2011-10-03 08:17:14.000000000 +0000
   3.386 ++++ mpfr-3.1.0/tests/tsprintf.c	2011-11-03 15:15:11.000000000 +0000
   3.387 +@@ -475,6 +475,18 @@
   3.388 +   check_sprintf ("-1.", "%- #0.1RG", x);
   3.389 + 
   3.390 +   /* precision zero */
   3.391 ++  mpfr_set_d (x, 9.5, MPFR_RNDN);
   3.392 ++  check_sprintf ("9",    "%.0RDf", x);
   3.393 ++  check_sprintf ("10",    "%.0RUf", x);
   3.394 ++
   3.395 ++  mpfr_set_d (x, 19.5, MPFR_RNDN);
   3.396 ++  check_sprintf ("19",    "%.0RDf", x);
   3.397 ++  check_sprintf ("20",    "%.0RUf", x);
   3.398 ++
   3.399 ++  mpfr_set_d (x, 99.5, MPFR_RNDN);
   3.400 ++  check_sprintf ("99",    "%.0RDf", x);
   3.401 ++  check_sprintf ("100",   "%.0RUf", x);
   3.402 ++
   3.403 +   mpfr_set_d (x, -9.5, MPFR_RNDN);
   3.404 +   check_sprintf ("-10",    "%.0RDf", x);
   3.405 +   check_sprintf ("-10",    "%.0RYf", x);
   3.406 +@@ -1078,6 +1090,23 @@
   3.407 +   mpfr_clear (x);
   3.408 + }
   3.409 + 
   3.410 ++static void
   3.411 ++bug20111102 (void)
   3.412 ++{
   3.413 ++  mpfr_t t;
   3.414 ++  char s[100];
   3.415 ++
   3.416 ++  mpfr_init2 (t, 84);
   3.417 ++  mpfr_set_str (t, "999.99999999999999999999", 10, MPFR_RNDN);
   3.418 ++  mpfr_sprintf (s, "%.20RNg", t);
   3.419 ++  if (strcmp (s, "1000") != 0)
   3.420 ++    {
   3.421 ++      printf ("Error in bug20111102, expected 1000, got %s\n", s);
   3.422 ++      exit (1);
   3.423 ++    }
   3.424 ++  mpfr_clear (t);
   3.425 ++}
   3.426 ++
   3.427 + /* In particular, the following test makes sure that the rounding
   3.428 +  * for %Ra and %Rb is not done on the MPFR number itself (as it
   3.429 +  * would overflow). Note: it has been reported on comp.std.c that
   3.430 +@@ -1161,6 +1190,7 @@
   3.431 +   locale = setlocale (LC_ALL, "C");
   3.432 + #endif
   3.433 + 
   3.434 ++  bug20111102 ();
   3.435 +   native_types ();
   3.436 +   hexadecimal ();
   3.437 +   binary ();
   3.438 +diff -Naur mpfr-3.1.0.orig/tests/turandom.c mpfr-3.1.0/tests/turandom.c
   3.439 +--- mpfr-3.1.0.orig/tests/turandom.c	2011-10-03 08:17:14.000000000 +0000
   3.440 ++++ mpfr-3.1.0/tests/turandom.c	2011-11-28 12:22:52.000000000 +0000
   3.441 +@@ -160,23 +160,29 @@
   3.442 +   mpfr_t x;
   3.443 +   gmp_randstate_t s;
   3.444 + 
   3.445 ++#if __MPFR_GMP(4,2,0)
   3.446 ++# define C1 "0.8488312"
   3.447 ++# define C2 "0.8156509"
   3.448 ++#else
   3.449 ++# define C1 "0.6485367"
   3.450 ++# define C2 "0.9362717"
   3.451 ++#endif
   3.452 ++
   3.453 +   gmp_randinit_default (s);
   3.454 +   gmp_randseed_ui (s, 42);
   3.455 +   mpfr_init2 (x, 17);
   3.456 +   mpfr_urandom (x, s, MPFR_RNDN);
   3.457 +-  /* the following values are obtained on a 32-bit computer, we should get
   3.458 +-     the same values on a 64-bit computer */
   3.459 +-  if (mpfr_cmp_str1 (x, "0.8488312") != 0)
   3.460 ++  if (mpfr_cmp_str1 (x, C1) != 0)
   3.461 +     {
   3.462 +-      printf ("Error in bug20100914, expected 0.8488312, got ");
   3.463 ++      printf ("Error in bug20100914, expected " C1 ", got ");
   3.464 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.465 +       printf ("\n");
   3.466 +       exit (1);
   3.467 +     }
   3.468 +   mpfr_urandom (x, s, MPFR_RNDN);
   3.469 +-  if (mpfr_cmp_str1 (x, "0.8156509") != 0)
   3.470 ++  if (mpfr_cmp_str1 (x, C2) != 0)
   3.471 +     {
   3.472 +-      printf ("Error in bug20100914, expected 0.8156509, got ");
   3.473 ++      printf ("Error in bug20100914, expected " C2 ", got ");
   3.474 +       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.475 +       printf ("\n");
   3.476 +       exit (1);