wok rev 7497

Up: mpfr to 3.0.0p8.
author Christopher Rogers <slaxemulator@gmail.com>
date Fri Dec 03 19:06:59 2010 +0000 (2010-12-03)
parents 57363c97e5a8
children eae5abfd796b
files mpfr-dev/receipt mpfr/receipt mpfr/stuff/mpfr-3.0.0-p4.patch mpfr/stuff/mpfr-3.0.0-p8.patch
line diff
     1.1 --- a/mpfr-dev/receipt	Fri Dec 03 18:31:30 2010 +0000
     1.2 +++ b/mpfr-dev/receipt	Fri Dec 03 19:06:59 2010 +0000
     1.3 @@ -5,9 +5,10 @@
     1.4  CATEGORY="development"
     1.5  SHORT_DESC="GNU Multiple Precision Arithmetic devel files."
     1.6  MAINTAINER="pankso@slitaz.org"
     1.7 +DEPENDS="mpfr"
     1.8  WANTED="mpfr"
     1.9  WEB_SITE="http://gmplib.org/"
    1.10 -EXTRAVERSION="p4"
    1.11 +EXTRAVERSION="p8"
    1.12  
    1.13  # Rules to gen a SliTaz package suitable for Tazpkg.
    1.14  genpkg_rules()
     2.1 --- a/mpfr/receipt	Fri Dec 03 18:31:30 2010 +0000
     2.2 +++ b/mpfr/receipt	Fri Dec 03 19:06:59 2010 +0000
     2.3 @@ -10,13 +10,13 @@
     2.4  TARBALL="$PACKAGE-$VERSION.tar.bz2"
     2.5  WEB_SITE="http://www.mpfr.org/"
     2.6  WGET_URL="http://www.mpfr.org/mpfr-current/$TARBALL"
     2.7 -EXTRAVERSION="p4"
     2.8 +EXTRAVERSION="p8"
     2.9  
    2.10  # Rules to configure and make the package.
    2.11  compile_rules()
    2.12  {	
    2.13  	cd $src
    2.14 -	patch -Np1 -i ../stuff/mpfr-3.0.0-p4.patch 
    2.15 +	patch -Np1 -i ../stuff/$PACKAGE-$VERSION-$EXTRAVERSION.patch 
    2.16  	./configure \
    2.17  		--prefix=/usr \
    2.18  		--infodir=/usr/share/info \
     3.1 --- a/mpfr/stuff/mpfr-3.0.0-p4.patch	Fri Dec 03 18:31:30 2010 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,924 +0,0 @@
     3.4 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
     3.5 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:02:49.000000000 +0000
     3.6 -+++ mpfr-3.0.0-b/PATCHES	2010-06-23 11:03:36.000000000 +0000
     3.7 -@@ -0,0 +1 @@
     3.8 -+mpfr_out_str
     3.9 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
    3.10 ---- mpfr-3.0.0-a/VERSION	2010-06-10 11:00:14.000000000 +0000
    3.11 -+++ mpfr-3.0.0-b/VERSION	2010-06-23 11:03:20.000000000 +0000
    3.12 -@@ -1 +1 @@
    3.13 --3.0.0
    3.14 -+3.0.0-p1
    3.15 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
    3.16 ---- mpfr-3.0.0-a/mpfr.h	2010-06-10 11:00:14.000000000 +0000
    3.17 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-23 11:03:20.000000000 +0000
    3.18 -@@ -27,7 +27,7 @@
    3.19 - #define MPFR_VERSION_MAJOR 3
    3.20 - #define MPFR_VERSION_MINOR 0
    3.21 - #define MPFR_VERSION_PATCHLEVEL 0
    3.22 --#define MPFR_VERSION_STRING "3.0.0"
    3.23 -+#define MPFR_VERSION_STRING "3.0.0-p1"
    3.24 - 
    3.25 - /* Macros dealing with MPFR VERSION */
    3.26 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    3.27 -diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
    3.28 ---- mpfr-3.0.0-a/mpfr.texi	2010-06-10 11:00:14.000000000 +0000
    3.29 -+++ mpfr-3.0.0-b/mpfr.texi	2010-06-23 11:03:12.000000000 +0000
    3.30 -@@ -2050,7 +2050,7 @@
    3.31 - are printed. If @var{base} is greater than 10, @samp{@@} will be used
    3.32 - instead of @samp{e} as exponent delimiter.
    3.33 - 
    3.34 --Return the number of bytes written, or if an error occurred, return 0.
    3.35 -+Return the number of characters written, or if an error occurred, return 0.
    3.36 - @end deftypefun
    3.37 - 
    3.38 - @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
    3.39 -diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
    3.40 ---- mpfr-3.0.0-a/out_str.c	2010-06-10 11:00:14.000000000 +0000
    3.41 -+++ mpfr-3.0.0-b/out_str.c	2010-06-23 11:03:12.000000000 +0000
    3.42 -@@ -22,6 +22,16 @@
    3.43 - 
    3.44 - #include "mpfr-impl.h"
    3.45 - 
    3.46 -+/* Warning! S should not contain "%". */
    3.47 -+#define OUT_STR_RET(S)                          \
    3.48 -+  do                                            \
    3.49 -+    {                                           \
    3.50 -+      int r;                                    \
    3.51 -+      r = fprintf (stream, (S));                \
    3.52 -+      return r < 0 ? 0 : r;                     \
    3.53 -+    }                                           \
    3.54 -+  while (0)
    3.55 -+
    3.56 - size_t
    3.57 - mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
    3.58 -               mpfr_rnd_t rnd_mode)
    3.59 -@@ -29,6 +39,7 @@
    3.60 -   char *s, *s0;
    3.61 -   size_t l;
    3.62 -   mpfr_exp_t e;
    3.63 -+  int err;
    3.64 - 
    3.65 -   MPFR_ASSERTN (base >= 2 && base <= 62);
    3.66 - 
    3.67 -@@ -36,37 +47,16 @@
    3.68 -   if (stream == NULL)
    3.69 -     stream = stdout;
    3.70 - 
    3.71 --  if (MPFR_IS_NAN(op))
    3.72 --    {
    3.73 --      fprintf (stream, "@NaN@");
    3.74 --      return 3;
    3.75 --    }
    3.76 --
    3.77 --  if (MPFR_IS_INF(op))
    3.78 --    {
    3.79 --      if (MPFR_SIGN(op) > 0)
    3.80 --        {
    3.81 --          fprintf (stream, "@Inf@");
    3.82 --          return 3;
    3.83 --        }
    3.84 --      else
    3.85 --        {
    3.86 --          fprintf (stream, "-@Inf@");
    3.87 --          return 4;
    3.88 --        }
    3.89 --    }
    3.90 --
    3.91 --  if (MPFR_IS_ZERO(op))
    3.92 -+  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
    3.93 -     {
    3.94 --      if (MPFR_SIGN(op) > 0)
    3.95 --        {
    3.96 --          fprintf(stream, "0");
    3.97 --          return 1;
    3.98 --        }
    3.99 -+      if (MPFR_IS_NAN (op))
   3.100 -+        OUT_STR_RET ("@NaN@");
   3.101 -+      else if (MPFR_IS_INF (op))
   3.102 -+        OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
   3.103 -       else
   3.104 -         {
   3.105 --          fprintf(stream, "-0");
   3.106 --          return 2;
   3.107 -+          MPFR_ASSERTD (MPFR_IS_ZERO (op));
   3.108 -+          OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
   3.109 -         }
   3.110 -     }
   3.111 - 
   3.112 -@@ -77,21 +67,31 @@
   3.113 - 
   3.114 -   l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
   3.115 -                          - may be incorrect, as only an upper bound? */
   3.116 --  if (*s == '-')
   3.117 --    fputc (*s++, stream);
   3.118 - 
   3.119 --  /* outputs mantissa */
   3.120 --  fputc (*s++, stream); e--; /* leading digit */
   3.121 --  fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
   3.122 --  fputs (s, stream);         /* rest of mantissa */
   3.123 -+  /* outputs possible sign and significand */
   3.124 -+  err = (*s == '-' && fputc (*s++, stream) == EOF)
   3.125 -+    || fputc (*s++, stream) == EOF  /* leading digit */
   3.126 -+    || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
   3.127 -+    || fputs (s, stream) == EOF;     /* trailing significand */
   3.128 -   (*__gmp_free_func) (s0, l);
   3.129 -+  if (MPFR_UNLIKELY (err))
   3.130 -+    return 0;
   3.131 -+
   3.132 -+  e--;  /* due to the leading digit */
   3.133 - 
   3.134 -   /* outputs exponent */
   3.135 -   if (e)
   3.136 -     {
   3.137 -+      int r;
   3.138 -+
   3.139 -       MPFR_ASSERTN(e >= LONG_MIN);
   3.140 -       MPFR_ASSERTN(e <= LONG_MAX);
   3.141 --      l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   3.142 -+
   3.143 -+      r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   3.144 -+      if (MPFR_UNLIKELY (r < 0))
   3.145 -+        return 0;
   3.146 -+
   3.147 -+      l += r;
   3.148 -     }
   3.149 - 
   3.150 -   return l;
   3.151 -diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
   3.152 ---- mpfr-3.0.0-a/tests/tout_str.c	2010-06-10 11:00:13.000000000 +0000
   3.153 -+++ mpfr-3.0.0-b/tests/tout_str.c	2010-06-23 11:03:12.000000000 +0000
   3.154 -@@ -46,22 +46,54 @@
   3.155 - special (void)
   3.156 - {
   3.157 -   mpfr_t x;
   3.158 -+  unsigned int n;
   3.159 - 
   3.160 -   mpfr_init (x);
   3.161 - 
   3.162 -   mpfr_set_nan (x);
   3.163 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.164 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.165 -+  if (n != 5)
   3.166 -+    {
   3.167 -+      printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
   3.168 -+              "characters instead of 5.\n", n);
   3.169 -+      exit (1);
   3.170 -+    }
   3.171 - 
   3.172 -   mpfr_set_inf (x, 1);
   3.173 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.174 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.175 -+  if (n != 5)
   3.176 -+    {
   3.177 -+      printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
   3.178 -+               "characters instead of 5.\n", n);
   3.179 -+      exit (1);
   3.180 -+    }
   3.181 - 
   3.182 -   mpfr_set_inf (x, -1);
   3.183 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.184 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.185 -+  if (n != 6)
   3.186 -+    {
   3.187 -+      printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
   3.188 -+               "characters instead of 6.\n", n);
   3.189 -+      exit (1);
   3.190 -+    }
   3.191 - 
   3.192 -   mpfr_set_ui (x, 0, MPFR_RNDN);
   3.193 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.194 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.195 -+  if (n != 1)
   3.196 -+    {
   3.197 -+      printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
   3.198 -+               "characters instead of 1.\n", n);
   3.199 -+      exit (1);
   3.200 -+    }
   3.201 -+
   3.202 -   mpfr_neg (x, x, MPFR_RNDN);
   3.203 --  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.204 -+  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   3.205 -+  if (n != 2)
   3.206 -+    {
   3.207 -+      printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
   3.208 -+               "characters instead of 2.\n", n);
   3.209 -+      exit (1);
   3.210 -+    }
   3.211 - 
   3.212 -   mpfr_clear (x);
   3.213 - }
   3.214 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.215 ---- mpfr-3.0.0-a/version.c	2010-06-10 11:00:14.000000000 +0000
   3.216 -+++ mpfr-3.0.0-b/version.c	2010-06-23 11:03:20.000000000 +0000
   3.217 -@@ -25,5 +25,5 @@
   3.218 - const char *
   3.219 - mpfr_get_version (void)
   3.220 - {
   3.221 --  return "3.0.0";
   3.222 -+  return "3.0.0-p1";
   3.223 - }
   3.224 -diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
   3.225 ---- mpfr-3.0.0-a/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.226 -+++ mpfr-3.0.0-b/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.227 -@@ -239,6 +239,7 @@
   3.228 - distuninstallcheck_listfiles = find . -type f -print
   3.229 - distcleancheck_listfiles = find . -type f -print
   3.230 - ACLOCAL = @ACLOCAL@
   3.231 -+ALLOCA = @ALLOCA@
   3.232 - AMTAR = @AMTAR@
   3.233 - AR = @AR@
   3.234 - AS = @AS@
   3.235 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.236 ---- mpfr-3.0.0-a/PATCHES	2010-06-23 11:03:36.000000000 +0000
   3.237 -+++ mpfr-3.0.0-b/PATCHES	2010-06-25 13:23:13.000000000 +0000
   3.238 -@@ -0,0 +1 @@
   3.239 -+alloca
   3.240 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.241 ---- mpfr-3.0.0-a/VERSION	2010-06-23 11:03:20.000000000 +0000
   3.242 -+++ mpfr-3.0.0-b/VERSION	2010-06-25 13:23:13.000000000 +0000
   3.243 -@@ -1 +1 @@
   3.244 --3.0.0-p1
   3.245 -+3.0.0-p2
   3.246 -diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
   3.247 ---- mpfr-3.0.0-a/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   3.248 -+++ mpfr-3.0.0-b/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   3.249 -@@ -59,6 +59,9 @@
   3.250 - dnl sys/fpu.h - MIPS specific
   3.251 - AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
   3.252 - 
   3.253 -+dnl Check how to get `alloca'
   3.254 -+AC_FUNC_ALLOCA
   3.255 -+
   3.256 - dnl SIZE_MAX macro
   3.257 - gl_SIZE_MAX
   3.258 - 
   3.259 -diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
   3.260 ---- mpfr-3.0.0-a/configure	2010-06-10 11:00:51.000000000 +0000
   3.261 -+++ mpfr-3.0.0-b/configure	2010-06-25 13:23:05.000000000 +0000
   3.262 -@@ -783,6 +783,7 @@
   3.263 - OBJDUMP
   3.264 - DLLTOOL
   3.265 - AS
   3.266 -+ALLOCA
   3.267 - MPFR_LIBM
   3.268 - ANSI2KNR
   3.269 - U
   3.270 -@@ -5622,6 +5623,197 @@
   3.271 - done
   3.272 - 
   3.273 - 
   3.274 -+# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
   3.275 -+# for constant arguments.  Useless!
   3.276 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
   3.277 -+$as_echo_n "checking for working alloca.h... " >&6; }
   3.278 -+if test "${ac_cv_working_alloca_h+set}" = set; then :
   3.279 -+  $as_echo_n "(cached) " >&6
   3.280 -+else
   3.281 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.282 -+/* end confdefs.h.  */
   3.283 -+#include <alloca.h>
   3.284 -+int
   3.285 -+main ()
   3.286 -+{
   3.287 -+char *p = (char *) alloca (2 * sizeof (int));
   3.288 -+			  if (p) return 0;
   3.289 -+  ;
   3.290 -+  return 0;
   3.291 -+}
   3.292 -+_ACEOF
   3.293 -+if ac_fn_c_try_link "$LINENO"; then :
   3.294 -+  ac_cv_working_alloca_h=yes
   3.295 -+else
   3.296 -+  ac_cv_working_alloca_h=no
   3.297 -+fi
   3.298 -+rm -f core conftest.err conftest.$ac_objext \
   3.299 -+    conftest$ac_exeext conftest.$ac_ext
   3.300 -+fi
   3.301 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
   3.302 -+$as_echo "$ac_cv_working_alloca_h" >&6; }
   3.303 -+if test $ac_cv_working_alloca_h = yes; then
   3.304 -+
   3.305 -+$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
   3.306 -+
   3.307 -+fi
   3.308 -+
   3.309 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
   3.310 -+$as_echo_n "checking for alloca... " >&6; }
   3.311 -+if test "${ac_cv_func_alloca_works+set}" = set; then :
   3.312 -+  $as_echo_n "(cached) " >&6
   3.313 -+else
   3.314 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.315 -+/* end confdefs.h.  */
   3.316 -+#ifdef __GNUC__
   3.317 -+# define alloca __builtin_alloca
   3.318 -+#else
   3.319 -+# ifdef _MSC_VER
   3.320 -+#  include <malloc.h>
   3.321 -+#  define alloca _alloca
   3.322 -+# else
   3.323 -+#  ifdef HAVE_ALLOCA_H
   3.324 -+#   include <alloca.h>
   3.325 -+#  else
   3.326 -+#   ifdef _AIX
   3.327 -+ #pragma alloca
   3.328 -+#   else
   3.329 -+#    ifndef alloca /* predefined by HP cc +Olibcalls */
   3.330 -+char *alloca ();
   3.331 -+#    endif
   3.332 -+#   endif
   3.333 -+#  endif
   3.334 -+# endif
   3.335 -+#endif
   3.336 -+
   3.337 -+int
   3.338 -+main ()
   3.339 -+{
   3.340 -+char *p = (char *) alloca (1);
   3.341 -+				    if (p) return 0;
   3.342 -+  ;
   3.343 -+  return 0;
   3.344 -+}
   3.345 -+_ACEOF
   3.346 -+if ac_fn_c_try_link "$LINENO"; then :
   3.347 -+  ac_cv_func_alloca_works=yes
   3.348 -+else
   3.349 -+  ac_cv_func_alloca_works=no
   3.350 -+fi
   3.351 -+rm -f core conftest.err conftest.$ac_objext \
   3.352 -+    conftest$ac_exeext conftest.$ac_ext
   3.353 -+fi
   3.354 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
   3.355 -+$as_echo "$ac_cv_func_alloca_works" >&6; }
   3.356 -+
   3.357 -+if test $ac_cv_func_alloca_works = yes; then
   3.358 -+
   3.359 -+$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
   3.360 -+
   3.361 -+else
   3.362 -+  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
   3.363 -+# that cause trouble.  Some versions do not even contain alloca or
   3.364 -+# contain a buggy version.  If you still want to use their alloca,
   3.365 -+# use ar to extract alloca.o from them instead of compiling alloca.c.
   3.366 -+
   3.367 -+ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
   3.368 -+
   3.369 -+$as_echo "#define C_ALLOCA 1" >>confdefs.h
   3.370 -+
   3.371 -+
   3.372 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
   3.373 -+$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
   3.374 -+if test "${ac_cv_os_cray+set}" = set; then :
   3.375 -+  $as_echo_n "(cached) " >&6
   3.376 -+else
   3.377 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.378 -+/* end confdefs.h.  */
   3.379 -+#if defined CRAY && ! defined CRAY2
   3.380 -+webecray
   3.381 -+#else
   3.382 -+wenotbecray
   3.383 -+#endif
   3.384 -+
   3.385 -+_ACEOF
   3.386 -+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   3.387 -+  $EGREP "webecray" >/dev/null 2>&1; then :
   3.388 -+  ac_cv_os_cray=yes
   3.389 -+else
   3.390 -+  ac_cv_os_cray=no
   3.391 -+fi
   3.392 -+rm -f conftest*
   3.393 -+
   3.394 -+fi
   3.395 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
   3.396 -+$as_echo "$ac_cv_os_cray" >&6; }
   3.397 -+if test $ac_cv_os_cray = yes; then
   3.398 -+  for ac_func in _getb67 GETB67 getb67; do
   3.399 -+    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   3.400 -+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   3.401 -+eval as_val=\$$as_ac_var
   3.402 -+   if test "x$as_val" = x""yes; then :
   3.403 -+
   3.404 -+cat >>confdefs.h <<_ACEOF
   3.405 -+#define CRAY_STACKSEG_END $ac_func
   3.406 -+_ACEOF
   3.407 -+
   3.408 -+    break
   3.409 -+fi
   3.410 -+
   3.411 -+  done
   3.412 -+fi
   3.413 -+
   3.414 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
   3.415 -+$as_echo_n "checking stack direction for C alloca... " >&6; }
   3.416 -+if test "${ac_cv_c_stack_direction+set}" = set; then :
   3.417 -+  $as_echo_n "(cached) " >&6
   3.418 -+else
   3.419 -+  if test "$cross_compiling" = yes; then :
   3.420 -+  ac_cv_c_stack_direction=0
   3.421 -+else
   3.422 -+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   3.423 -+/* end confdefs.h.  */
   3.424 -+$ac_includes_default
   3.425 -+int
   3.426 -+find_stack_direction ()
   3.427 -+{
   3.428 -+  static char *addr = 0;
   3.429 -+  auto char dummy;
   3.430 -+  if (addr == 0)
   3.431 -+    {
   3.432 -+      addr = &dummy;
   3.433 -+      return find_stack_direction ();
   3.434 -+    }
   3.435 -+  else
   3.436 -+    return (&dummy > addr) ? 1 : -1;
   3.437 -+}
   3.438 -+
   3.439 -+int
   3.440 -+main ()
   3.441 -+{
   3.442 -+  return find_stack_direction () < 0;
   3.443 -+}
   3.444 -+_ACEOF
   3.445 -+if ac_fn_c_try_run "$LINENO"; then :
   3.446 -+  ac_cv_c_stack_direction=1
   3.447 -+else
   3.448 -+  ac_cv_c_stack_direction=-1
   3.449 -+fi
   3.450 -+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   3.451 -+  conftest.$ac_objext conftest.beam conftest.$ac_ext
   3.452 -+fi
   3.453 -+
   3.454 -+fi
   3.455 -+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
   3.456 -+$as_echo "$ac_cv_c_stack_direction" >&6; }
   3.457 -+cat >>confdefs.h <<_ACEOF
   3.458 -+#define STACK_DIRECTION $ac_cv_c_stack_direction
   3.459 -+_ACEOF
   3.460 -+
   3.461 -+
   3.462 -+fi
   3.463 -+
   3.464 -+
   3.465 - 
   3.466 -   for ac_header in stdint.h
   3.467 - do :
   3.468 -@@ -7564,13 +7756,13 @@
   3.469 - else
   3.470 -   lt_cv_nm_interface="BSD nm"
   3.471 -   echo "int some_variable = 0;" > conftest.$ac_ext
   3.472 --  (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
   3.473 -+  (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
   3.474 -   (eval "$ac_compile" 2>conftest.err)
   3.475 -   cat conftest.err >&5
   3.476 --  (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   3.477 -+  (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   3.478 -   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   3.479 -   cat conftest.err >&5
   3.480 --  (eval echo "\"\$as_me:7573: output\"" >&5)
   3.481 -+  (eval echo "\"\$as_me:7765: output\"" >&5)
   3.482 -   cat conftest.out >&5
   3.483 -   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
   3.484 -     lt_cv_nm_interface="MS dumpbin"
   3.485 -@@ -8772,7 +8964,7 @@
   3.486 -   ;;
   3.487 - *-*-irix6*)
   3.488 -   # Find out which ABI we are using.
   3.489 --  echo '#line 8775 "configure"' > conftest.$ac_ext
   3.490 -+  echo '#line 8967 "configure"' > conftest.$ac_ext
   3.491 -   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   3.492 -   (eval $ac_compile) 2>&5
   3.493 -   ac_status=$?
   3.494 -@@ -10032,11 +10224,11 @@
   3.495 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.496 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.497 -    -e 's:$: $lt_compiler_flag:'`
   3.498 --   (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
   3.499 -+   (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
   3.500 -    (eval "$lt_compile" 2>conftest.err)
   3.501 -    ac_status=$?
   3.502 -    cat conftest.err >&5
   3.503 --   echo "$as_me:10039: \$? = $ac_status" >&5
   3.504 -+   echo "$as_me:10231: \$? = $ac_status" >&5
   3.505 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   3.506 -      # The compiler can only warn and ignore the option if not recognized
   3.507 -      # So say no if there are warnings other than the usual output.
   3.508 -@@ -10371,11 +10563,11 @@
   3.509 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.510 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.511 -    -e 's:$: $lt_compiler_flag:'`
   3.512 --   (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
   3.513 -+   (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
   3.514 -    (eval "$lt_compile" 2>conftest.err)
   3.515 -    ac_status=$?
   3.516 -    cat conftest.err >&5
   3.517 --   echo "$as_me:10378: \$? = $ac_status" >&5
   3.518 -+   echo "$as_me:10570: \$? = $ac_status" >&5
   3.519 -    if (exit $ac_status) && test -s "$ac_outfile"; then
   3.520 -      # The compiler can only warn and ignore the option if not recognized
   3.521 -      # So say no if there are warnings other than the usual output.
   3.522 -@@ -10476,11 +10668,11 @@
   3.523 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.524 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.525 -    -e 's:$: $lt_compiler_flag:'`
   3.526 --   (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
   3.527 -+   (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
   3.528 -    (eval "$lt_compile" 2>out/conftest.err)
   3.529 -    ac_status=$?
   3.530 -    cat out/conftest.err >&5
   3.531 --   echo "$as_me:10483: \$? = $ac_status" >&5
   3.532 -+   echo "$as_me:10675: \$? = $ac_status" >&5
   3.533 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   3.534 -    then
   3.535 -      # The compiler can only warn and ignore the option if not recognized
   3.536 -@@ -10531,11 +10723,11 @@
   3.537 -    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   3.538 -    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   3.539 -    -e 's:$: $lt_compiler_flag:'`
   3.540 --   (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
   3.541 -+   (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
   3.542 -    (eval "$lt_compile" 2>out/conftest.err)
   3.543 -    ac_status=$?
   3.544 -    cat out/conftest.err >&5
   3.545 --   echo "$as_me:10538: \$? = $ac_status" >&5
   3.546 -+   echo "$as_me:10730: \$? = $ac_status" >&5
   3.547 -    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   3.548 -    then
   3.549 -      # The compiler can only warn and ignore the option if not recognized
   3.550 -@@ -12915,7 +13107,7 @@
   3.551 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   3.552 -   lt_status=$lt_dlunknown
   3.553 -   cat > conftest.$ac_ext <<_LT_EOF
   3.554 --#line 12918 "configure"
   3.555 -+#line 13110 "configure"
   3.556 - #include "confdefs.h"
   3.557 - 
   3.558 - #if HAVE_DLFCN_H
   3.559 -@@ -13011,7 +13203,7 @@
   3.560 -   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   3.561 -   lt_status=$lt_dlunknown
   3.562 -   cat > conftest.$ac_ext <<_LT_EOF
   3.563 --#line 13014 "configure"
   3.564 -+#line 13206 "configure"
   3.565 - #include "confdefs.h"
   3.566 - 
   3.567 - #if HAVE_DLFCN_H
   3.568 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.569 ---- mpfr-3.0.0-a/mpfr.h	2010-06-23 11:03:20.000000000 +0000
   3.570 -+++ mpfr-3.0.0-b/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   3.571 -@@ -27,7 +27,7 @@
   3.572 - #define MPFR_VERSION_MAJOR 3
   3.573 - #define MPFR_VERSION_MINOR 0
   3.574 - #define MPFR_VERSION_PATCHLEVEL 0
   3.575 --#define MPFR_VERSION_STRING "3.0.0-p1"
   3.576 -+#define MPFR_VERSION_STRING "3.0.0-p2"
   3.577 - 
   3.578 - /* Macros dealing with MPFR VERSION */
   3.579 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.580 -diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
   3.581 ---- mpfr-3.0.0-a/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.582 -+++ mpfr-3.0.0-b/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   3.583 -@@ -960,6 +960,7 @@
   3.584 - red=; grn=; lgn=; blu=; std=
   3.585 - DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   3.586 - ACLOCAL = @ACLOCAL@
   3.587 -+ALLOCA = @ALLOCA@
   3.588 - AMTAR = @AMTAR@
   3.589 - AR = @AR@
   3.590 - AS = @AS@
   3.591 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.592 ---- mpfr-3.0.0-a/version.c	2010-06-23 11:03:20.000000000 +0000
   3.593 -+++ mpfr-3.0.0-b/version.c	2010-06-25 13:23:13.000000000 +0000
   3.594 -@@ -25,5 +25,5 @@
   3.595 - const char *
   3.596 - mpfr_get_version (void)
   3.597 - {
   3.598 --  return "3.0.0-p1";
   3.599 -+  return "3.0.0-p2";
   3.600 - }
   3.601 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.602 ---- mpfr-3.0.0-a/PATCHES	2010-07-10 00:11:19.000000000 +0000
   3.603 -+++ mpfr-3.0.0-b/PATCHES	2010-07-10 00:12:50.000000000 +0000
   3.604 -@@ -0,0 +1 @@
   3.605 -+gamma_underflow
   3.606 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.607 ---- mpfr-3.0.0-a/VERSION	2010-06-25 13:23:13.000000000 +0000
   3.608 -+++ mpfr-3.0.0-b/VERSION	2010-07-10 00:11:53.000000000 +0000
   3.609 -@@ -1 +1 @@
   3.610 --3.0.0-p2
   3.611 -+3.0.0-p3
   3.612 -diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
   3.613 ---- mpfr-3.0.0-a/gamma.c	2010-06-10 11:00:14.000000000 +0000
   3.614 -+++ mpfr-3.0.0-b/gamma.c	2010-07-10 00:11:46.000000000 +0000
   3.615 -@@ -274,7 +274,7 @@
   3.616 -       /* we want an upper bound for x * [log(2-x)-1].
   3.617 -          since x < 0, we need a lower bound on log(2-x) */
   3.618 -       mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
   3.619 --      mpfr_log (xp, xp, MPFR_RNDD);
   3.620 -+      mpfr_log2 (xp, xp, MPFR_RNDD);
   3.621 -       mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
   3.622 -       mpfr_mul (xp, xp, x, MPFR_RNDU);
   3.623 - 
   3.624 -@@ -303,8 +303,8 @@
   3.625 -         {
   3.626 -           mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
   3.627 -           mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
   3.628 --          mpfr_log (tmp, tmp, MPFR_RNDU);
   3.629 --          mpfr_add (tmp, tmp, xp, MPFR_RNDU);
   3.630 -+          mpfr_log2 (tmp, tmp, MPFR_RNDU);
   3.631 -+          mpfr_add (xp, tmp, xp, MPFR_RNDU);
   3.632 -           underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
   3.633 -         }
   3.634 - 
   3.635 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.636 ---- mpfr-3.0.0-a/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   3.637 -+++ mpfr-3.0.0-b/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   3.638 -@@ -27,7 +27,7 @@
   3.639 - #define MPFR_VERSION_MAJOR 3
   3.640 - #define MPFR_VERSION_MINOR 0
   3.641 - #define MPFR_VERSION_PATCHLEVEL 0
   3.642 --#define MPFR_VERSION_STRING "3.0.0-p2"
   3.643 -+#define MPFR_VERSION_STRING "3.0.0-p3"
   3.644 - 
   3.645 - /* Macros dealing with MPFR VERSION */
   3.646 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.647 -diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
   3.648 ---- mpfr-3.0.0-a/tests/tgamma.c	2010-06-10 11:00:13.000000000 +0000
   3.649 -+++ mpfr-3.0.0-b/tests/tgamma.c	2010-07-10 00:11:46.000000000 +0000
   3.650 -@@ -461,6 +461,20 @@
   3.651 -   mpfr_clear (x);
   3.652 - }
   3.653 - 
   3.654 -+/* bug found by Stathis, only occurs on 32-bit machines */
   3.655 -+static void
   3.656 -+test20100709 (void)
   3.657 -+{
   3.658 -+  mpfr_t x;
   3.659 -+  int inex;
   3.660 -+
   3.661 -+  mpfr_init2 (x, 100);
   3.662 -+  mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
   3.663 -+  inex = mpfr_gamma (x, x, MPFR_RNDN);
   3.664 -+  MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
   3.665 -+  mpfr_clear (x);
   3.666 -+}
   3.667 -+
   3.668 - int
   3.669 - main (int argc, char *argv[])
   3.670 - {
   3.671 -@@ -471,6 +485,7 @@
   3.672 -   test_generic (2, 100, 2);
   3.673 -   gamma_integer ();
   3.674 -   test20071231 ();
   3.675 -+  test20100709 ();
   3.676 - 
   3.677 -   data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
   3.678 - 
   3.679 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.680 ---- mpfr-3.0.0-a/version.c	2010-06-25 13:23:13.000000000 +0000
   3.681 -+++ mpfr-3.0.0-b/version.c	2010-07-10 00:11:53.000000000 +0000
   3.682 -@@ -25,5 +25,5 @@
   3.683 - const char *
   3.684 - mpfr_get_version (void)
   3.685 - {
   3.686 --  return "3.0.0-p2";
   3.687 -+  return "3.0.0-p3";
   3.688 - }
   3.689 -diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   3.690 ---- mpfr-3.0.0-a/PATCHES	2010-09-07 08:44:01.000000000 +0000
   3.691 -+++ mpfr-3.0.0-b/PATCHES	2010-09-07 08:48:46.000000000 +0000
   3.692 -@@ -0,0 +1 @@
   3.693 -+mpfr_cmp/set_ui/si
   3.694 -diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   3.695 ---- mpfr-3.0.0-a/VERSION	2010-07-10 00:11:53.000000000 +0000
   3.696 -+++ mpfr-3.0.0-b/VERSION	2010-09-07 08:46:06.000000000 +0000
   3.697 -@@ -1 +1 @@
   3.698 --3.0.0-p3
   3.699 -+3.0.0-p4
   3.700 -diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   3.701 ---- mpfr-3.0.0-a/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   3.702 -+++ mpfr-3.0.0-b/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   3.703 -@@ -27,7 +27,7 @@
   3.704 - #define MPFR_VERSION_MAJOR 3
   3.705 - #define MPFR_VERSION_MINOR 0
   3.706 - #define MPFR_VERSION_PATCHLEVEL 0
   3.707 --#define MPFR_VERSION_STRING "3.0.0-p3"
   3.708 -+#define MPFR_VERSION_STRING "3.0.0-p4"
   3.709 - 
   3.710 - /* Macros dealing with MPFR VERSION */
   3.711 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.712 -@@ -798,35 +798,45 @@
   3.713 -      anyway. Checking with other ICC versions is needed. Possibly detect
   3.714 -      whether warnings are produced or not with a configure test.
   3.715 -    + Remove C++ too, since it complains too much. */
   3.716 -+/* Added casts to improve robustness in case of undefined behavior and
   3.717 -+   compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
   3.718 -+   use such extensions, but these macros will be used by 3rd-party code,
   3.719 -+   where such extensions may be required.
   3.720 -+   Moreover casts to unsigned long have been added to avoid warnings in
   3.721 -+   programs that use MPFR and are compiled with -Wconversion; such casts
   3.722 -+   are OK since if X is a constant expression, then (unsigned long) X is
   3.723 -+   also a constant expression, so that the optimizations still work. */
   3.724 - #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
   3.725 - #if (__GNUC__ >= 2)
   3.726 - #undef mpfr_cmp_ui
   3.727 --/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
   3.728 --#define mpfr_cmp_ui(_f,_u)                 \
   3.729 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   3.730 --   mpfr_sgn (_f) :                         \
   3.731 --   mpfr_cmp_ui_2exp ((_f),(_u),0))
   3.732 -+/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
   3.733 -+   But warning! mpfr_sgn is specified as a macro in the API, thus the macro
   3.734 -+   mustn't be used if side effects are possible, like here. */
   3.735 -+#define mpfr_cmp_ui(_f,_u)                                      \
   3.736 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   3.737 -+   (mpfr_sgn) (_f) :                                            \
   3.738 -+   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
   3.739 - #undef mpfr_cmp_si
   3.740 --#define mpfr_cmp_si(_f,_s)                 \
   3.741 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   3.742 --   mpfr_cmp_ui ((_f), (_s)) :              \
   3.743 --   mpfr_cmp_si_2exp ((_f), (_s), 0))
   3.744 -+#define mpfr_cmp_si(_f,_s)                              \
   3.745 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
   3.746 -+   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
   3.747 -+   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
   3.748 - #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
   3.749 - #undef mpfr_set_ui
   3.750 --#define mpfr_set_ui(_f,_u,_r)              \
   3.751 -- (__builtin_constant_p (_u) && (_u) == 0 ? \
   3.752 --   __extension__ ({                        \
   3.753 --     mpfr_ptr _p = (_f);                   \
   3.754 --     _p->_mpfr_sign = 1;                   \
   3.755 --     _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
   3.756 --     (void) (_r); 0; }) :                  \
   3.757 --   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
   3.758 -+#define mpfr_set_ui(_f,_u,_r)                                   \
   3.759 -+  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   3.760 -+   __extension__ ({                                             \
   3.761 -+       mpfr_ptr _p = (_f);                                      \
   3.762 -+       _p->_mpfr_sign = 1;                                      \
   3.763 -+       _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
   3.764 -+       (void) (_r); 0; }) :                                     \
   3.765 -+   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
   3.766 - #endif
   3.767 - #undef mpfr_set_si
   3.768 --#define mpfr_set_si(_f,_s,_r)              \
   3.769 -- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   3.770 --   mpfr_set_ui ((_f), (_s), (_r)) :        \
   3.771 --   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
   3.772 -+#define mpfr_set_si(_f,_s,_r)                                   \
   3.773 -+  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
   3.774 -+   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
   3.775 -+   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
   3.776 - #endif
   3.777 - #endif
   3.778 - 
   3.779 -diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
   3.780 ---- mpfr-3.0.0-a/tests/tcmp_ui.c	2010-06-10 11:00:13.000000000 +0000
   3.781 -+++ mpfr-3.0.0-b/tests/tcmp_ui.c	2010-09-07 08:45:12.000000000 +0000
   3.782 -@@ -88,6 +88,126 @@
   3.783 -   mpfr_clear (x);
   3.784 - }
   3.785 - 
   3.786 -+/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
   3.787 -+   with __builtin_constant_p for GCC, check that side effects are
   3.788 -+   handled correctly. */
   3.789 -+static void
   3.790 -+check_macros (void)
   3.791 -+{
   3.792 -+  mpfr_t x;
   3.793 -+  int c;
   3.794 -+
   3.795 -+  mpfr_init2 (x, 32);
   3.796 -+
   3.797 -+  c = 0;
   3.798 -+  mpfr_set_ui (x, 17, MPFR_RNDN);
   3.799 -+  if (mpfr_cmp_ui (x, 17) != 0)
   3.800 -+    {
   3.801 -+      printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
   3.802 -+      exit (1);
   3.803 -+    }
   3.804 -+  if (mpfr_cmp_ui (x, (c++, 17)) != 0)
   3.805 -+    {
   3.806 -+      printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
   3.807 -+      exit (1);
   3.808 -+    }
   3.809 -+  if (c != 1)
   3.810 -+    {
   3.811 -+      printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
   3.812 -+              "(c = %d instead of 1)\n", c);
   3.813 -+      exit (1);
   3.814 -+    }
   3.815 -+  if (mpfr_cmp_si (x, 17) != 0)
   3.816 -+    {
   3.817 -+      printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
   3.818 -+      exit (1);
   3.819 -+    }
   3.820 -+  if (mpfr_cmp_si (x, (c++, 17)) != 0)
   3.821 -+    {
   3.822 -+      printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
   3.823 -+      exit (1);
   3.824 -+    }
   3.825 -+  if (c != 2)
   3.826 -+    {
   3.827 -+      printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
   3.828 -+              "(c = %d instead of 2)\n", c);
   3.829 -+      exit (1);
   3.830 -+    }
   3.831 -+
   3.832 -+  c = 0;
   3.833 -+  mpfr_set_ui (x, 0, MPFR_RNDN);
   3.834 -+  if (mpfr_cmp_ui (x, 0) != 0)
   3.835 -+    {
   3.836 -+      printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
   3.837 -+      exit (1);
   3.838 -+    }
   3.839 -+  if (mpfr_cmp_ui (x, (c++, 0)) != 0)
   3.840 -+    {
   3.841 -+      printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
   3.842 -+      exit (1);
   3.843 -+    }
   3.844 -+  if (c != 1)
   3.845 -+    {
   3.846 -+      printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
   3.847 -+              "(c = %d instead of 1)\n", c);
   3.848 -+      exit (1);
   3.849 -+    }
   3.850 -+  if (mpfr_cmp_si (x, 0) != 0)
   3.851 -+    {
   3.852 -+      printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
   3.853 -+      exit (1);
   3.854 -+    }
   3.855 -+  if (mpfr_cmp_si (x, (c++, 0)) != 0)
   3.856 -+    {
   3.857 -+      printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
   3.858 -+      exit (1);
   3.859 -+    }
   3.860 -+  if (c != 2)
   3.861 -+    {
   3.862 -+      printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
   3.863 -+              "(c = %d instead of 2)\n", c);
   3.864 -+      exit (1);
   3.865 -+    }
   3.866 -+
   3.867 -+  mpfr_clear (x);
   3.868 -+}
   3.869 -+
   3.870 -+/* Bug in r7114 */
   3.871 -+static void
   3.872 -+test_macros (void)
   3.873 -+{
   3.874 -+  mpfr_t x[3];
   3.875 -+  mpfr_ptr p;
   3.876 -+
   3.877 -+  mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
   3.878 -+  mpfr_set_ui (x[0], 0, MPFR_RNDN);
   3.879 -+  p = x[0];
   3.880 -+  if (mpfr_cmp_ui (p++, 0) != 0)
   3.881 -+    {
   3.882 -+      printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
   3.883 -+      exit (1);
   3.884 -+    }
   3.885 -+  if (p != x[1])
   3.886 -+    {
   3.887 -+      printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
   3.888 -+              (int) (p - x[0]));
   3.889 -+      exit (1);
   3.890 -+    }
   3.891 -+  p = x[0];
   3.892 -+  if (mpfr_cmp_si (p++, 0) != 0)
   3.893 -+    {
   3.894 -+      printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
   3.895 -+      exit (1);
   3.896 -+    }
   3.897 -+  if (p != x[1])
   3.898 -+    {
   3.899 -+      printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
   3.900 -+              (int) (p - x[0]));
   3.901 -+      exit (1);
   3.902 -+    }
   3.903 -+  mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
   3.904 -+}
   3.905 -+
   3.906 - int
   3.907 - main (void)
   3.908 - {
   3.909 -@@ -216,6 +336,8 @@
   3.910 -   mpfr_clear (x);
   3.911 - 
   3.912 -   check_nan ();
   3.913 -+  check_macros ();
   3.914 -+  test_macros ();
   3.915 - 
   3.916 -   tests_end_mpfr ();
   3.917 -   return 0;
   3.918 -diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   3.919 ---- mpfr-3.0.0-a/version.c	2010-07-10 00:11:53.000000000 +0000
   3.920 -+++ mpfr-3.0.0-b/version.c	2010-09-07 08:46:06.000000000 +0000
   3.921 -@@ -25,5 +25,5 @@
   3.922 - const char *
   3.923 - mpfr_get_version (void)
   3.924 - {
   3.925 --  return "3.0.0-p3";
   3.926 -+  return "3.0.0-p4";
   3.927 - }
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/mpfr/stuff/mpfr-3.0.0-p8.patch	Fri Dec 03 19:06:59 2010 +0000
     4.3 @@ -0,0 +1,1945 @@
     4.4 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
     4.5 +--- mpfr-3.0.0-a/PATCHES	2010-06-23 11:02:49.000000000 +0000
     4.6 ++++ mpfr-3.0.0-b/PATCHES	2010-06-23 11:03:36.000000000 +0000
     4.7 +@@ -0,0 +1 @@
     4.8 ++mpfr_out_str
     4.9 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
    4.10 +--- mpfr-3.0.0-a/VERSION	2010-06-10 11:00:14.000000000 +0000
    4.11 ++++ mpfr-3.0.0-b/VERSION	2010-06-23 11:03:20.000000000 +0000
    4.12 +@@ -1 +1 @@
    4.13 +-3.0.0
    4.14 ++3.0.0-p1
    4.15 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
    4.16 +--- mpfr-3.0.0-a/mpfr.h	2010-06-10 11:00:14.000000000 +0000
    4.17 ++++ mpfr-3.0.0-b/mpfr.h	2010-06-23 11:03:20.000000000 +0000
    4.18 +@@ -27,7 +27,7 @@
    4.19 + #define MPFR_VERSION_MAJOR 3
    4.20 + #define MPFR_VERSION_MINOR 0
    4.21 + #define MPFR_VERSION_PATCHLEVEL 0
    4.22 +-#define MPFR_VERSION_STRING "3.0.0"
    4.23 ++#define MPFR_VERSION_STRING "3.0.0-p1"
    4.24 + 
    4.25 + /* Macros dealing with MPFR VERSION */
    4.26 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
    4.27 +diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
    4.28 +--- mpfr-3.0.0-a/mpfr.texi	2010-06-10 11:00:14.000000000 +0000
    4.29 ++++ mpfr-3.0.0-b/mpfr.texi	2010-06-23 11:03:12.000000000 +0000
    4.30 +@@ -2050,7 +2050,7 @@
    4.31 + are printed. If @var{base} is greater than 10, @samp{@@} will be used
    4.32 + instead of @samp{e} as exponent delimiter.
    4.33 + 
    4.34 +-Return the number of bytes written, or if an error occurred, return 0.
    4.35 ++Return the number of characters written, or if an error occurred, return 0.
    4.36 + @end deftypefun
    4.37 + 
    4.38 + @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
    4.39 +diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
    4.40 +--- mpfr-3.0.0-a/out_str.c	2010-06-10 11:00:14.000000000 +0000
    4.41 ++++ mpfr-3.0.0-b/out_str.c	2010-06-23 11:03:12.000000000 +0000
    4.42 +@@ -22,6 +22,16 @@
    4.43 + 
    4.44 + #include "mpfr-impl.h"
    4.45 + 
    4.46 ++/* Warning! S should not contain "%". */
    4.47 ++#define OUT_STR_RET(S)                          \
    4.48 ++  do                                            \
    4.49 ++    {                                           \
    4.50 ++      int r;                                    \
    4.51 ++      r = fprintf (stream, (S));                \
    4.52 ++      return r < 0 ? 0 : r;                     \
    4.53 ++    }                                           \
    4.54 ++  while (0)
    4.55 ++
    4.56 + size_t
    4.57 + mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
    4.58 +               mpfr_rnd_t rnd_mode)
    4.59 +@@ -29,6 +39,7 @@
    4.60 +   char *s, *s0;
    4.61 +   size_t l;
    4.62 +   mpfr_exp_t e;
    4.63 ++  int err;
    4.64 + 
    4.65 +   MPFR_ASSERTN (base >= 2 && base <= 62);
    4.66 + 
    4.67 +@@ -36,37 +47,16 @@
    4.68 +   if (stream == NULL)
    4.69 +     stream = stdout;
    4.70 + 
    4.71 +-  if (MPFR_IS_NAN(op))
    4.72 +-    {
    4.73 +-      fprintf (stream, "@NaN@");
    4.74 +-      return 3;
    4.75 +-    }
    4.76 +-
    4.77 +-  if (MPFR_IS_INF(op))
    4.78 +-    {
    4.79 +-      if (MPFR_SIGN(op) > 0)
    4.80 +-        {
    4.81 +-          fprintf (stream, "@Inf@");
    4.82 +-          return 3;
    4.83 +-        }
    4.84 +-      else
    4.85 +-        {
    4.86 +-          fprintf (stream, "-@Inf@");
    4.87 +-          return 4;
    4.88 +-        }
    4.89 +-    }
    4.90 +-
    4.91 +-  if (MPFR_IS_ZERO(op))
    4.92 ++  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
    4.93 +     {
    4.94 +-      if (MPFR_SIGN(op) > 0)
    4.95 +-        {
    4.96 +-          fprintf(stream, "0");
    4.97 +-          return 1;
    4.98 +-        }
    4.99 ++      if (MPFR_IS_NAN (op))
   4.100 ++        OUT_STR_RET ("@NaN@");
   4.101 ++      else if (MPFR_IS_INF (op))
   4.102 ++        OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
   4.103 +       else
   4.104 +         {
   4.105 +-          fprintf(stream, "-0");
   4.106 +-          return 2;
   4.107 ++          MPFR_ASSERTD (MPFR_IS_ZERO (op));
   4.108 ++          OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
   4.109 +         }
   4.110 +     }
   4.111 + 
   4.112 +@@ -77,21 +67,31 @@
   4.113 + 
   4.114 +   l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
   4.115 +                          - may be incorrect, as only an upper bound? */
   4.116 +-  if (*s == '-')
   4.117 +-    fputc (*s++, stream);
   4.118 + 
   4.119 +-  /* outputs mantissa */
   4.120 +-  fputc (*s++, stream); e--; /* leading digit */
   4.121 +-  fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
   4.122 +-  fputs (s, stream);         /* rest of mantissa */
   4.123 ++  /* outputs possible sign and significand */
   4.124 ++  err = (*s == '-' && fputc (*s++, stream) == EOF)
   4.125 ++    || fputc (*s++, stream) == EOF  /* leading digit */
   4.126 ++    || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
   4.127 ++    || fputs (s, stream) == EOF;     /* trailing significand */
   4.128 +   (*__gmp_free_func) (s0, l);
   4.129 ++  if (MPFR_UNLIKELY (err))
   4.130 ++    return 0;
   4.131 ++
   4.132 ++  e--;  /* due to the leading digit */
   4.133 + 
   4.134 +   /* outputs exponent */
   4.135 +   if (e)
   4.136 +     {
   4.137 ++      int r;
   4.138 ++
   4.139 +       MPFR_ASSERTN(e >= LONG_MIN);
   4.140 +       MPFR_ASSERTN(e <= LONG_MAX);
   4.141 +-      l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   4.142 ++
   4.143 ++      r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
   4.144 ++      if (MPFR_UNLIKELY (r < 0))
   4.145 ++        return 0;
   4.146 ++
   4.147 ++      l += r;
   4.148 +     }
   4.149 + 
   4.150 +   return l;
   4.151 +diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
   4.152 +--- mpfr-3.0.0-a/tests/tout_str.c	2010-06-10 11:00:13.000000000 +0000
   4.153 ++++ mpfr-3.0.0-b/tests/tout_str.c	2010-06-23 11:03:12.000000000 +0000
   4.154 +@@ -46,22 +46,54 @@
   4.155 + special (void)
   4.156 + {
   4.157 +   mpfr_t x;
   4.158 ++  unsigned int n;
   4.159 + 
   4.160 +   mpfr_init (x);
   4.161 + 
   4.162 +   mpfr_set_nan (x);
   4.163 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.164 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.165 ++  if (n != 5)
   4.166 ++    {
   4.167 ++      printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
   4.168 ++              "characters instead of 5.\n", n);
   4.169 ++      exit (1);
   4.170 ++    }
   4.171 + 
   4.172 +   mpfr_set_inf (x, 1);
   4.173 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.174 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.175 ++  if (n != 5)
   4.176 ++    {
   4.177 ++      printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
   4.178 ++               "characters instead of 5.\n", n);
   4.179 ++      exit (1);
   4.180 ++    }
   4.181 + 
   4.182 +   mpfr_set_inf (x, -1);
   4.183 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.184 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.185 ++  if (n != 6)
   4.186 ++    {
   4.187 ++      printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
   4.188 ++               "characters instead of 6.\n", n);
   4.189 ++      exit (1);
   4.190 ++    }
   4.191 + 
   4.192 +   mpfr_set_ui (x, 0, MPFR_RNDN);
   4.193 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.194 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.195 ++  if (n != 1)
   4.196 ++    {
   4.197 ++      printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
   4.198 ++               "characters instead of 1.\n", n);
   4.199 ++      exit (1);
   4.200 ++    }
   4.201 ++
   4.202 +   mpfr_neg (x, x, MPFR_RNDN);
   4.203 +-  mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.204 ++  n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
   4.205 ++  if (n != 2)
   4.206 ++    {
   4.207 ++      printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
   4.208 ++               "characters instead of 2.\n", n);
   4.209 ++      exit (1);
   4.210 ++    }
   4.211 + 
   4.212 +   mpfr_clear (x);
   4.213 + }
   4.214 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   4.215 +--- mpfr-3.0.0-a/version.c	2010-06-10 11:00:14.000000000 +0000
   4.216 ++++ mpfr-3.0.0-b/version.c	2010-06-23 11:03:20.000000000 +0000
   4.217 +@@ -25,5 +25,5 @@
   4.218 + const char *
   4.219 + mpfr_get_version (void)
   4.220 + {
   4.221 +-  return "3.0.0";
   4.222 ++  return "3.0.0-p1";
   4.223 + }
   4.224 +diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
   4.225 +--- mpfr-3.0.0-a/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   4.226 ++++ mpfr-3.0.0-b/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   4.227 +@@ -239,6 +239,7 @@
   4.228 + distuninstallcheck_listfiles = find . -type f -print
   4.229 + distcleancheck_listfiles = find . -type f -print
   4.230 + ACLOCAL = @ACLOCAL@
   4.231 ++ALLOCA = @ALLOCA@
   4.232 + AMTAR = @AMTAR@
   4.233 + AR = @AR@
   4.234 + AS = @AS@
   4.235 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   4.236 +--- mpfr-3.0.0-a/PATCHES	2010-06-23 11:03:36.000000000 +0000
   4.237 ++++ mpfr-3.0.0-b/PATCHES	2010-06-25 13:23:13.000000000 +0000
   4.238 +@@ -0,0 +1 @@
   4.239 ++alloca
   4.240 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   4.241 +--- mpfr-3.0.0-a/VERSION	2010-06-23 11:03:20.000000000 +0000
   4.242 ++++ mpfr-3.0.0-b/VERSION	2010-06-25 13:23:13.000000000 +0000
   4.243 +@@ -1 +1 @@
   4.244 +-3.0.0-p1
   4.245 ++3.0.0-p2
   4.246 +diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
   4.247 +--- mpfr-3.0.0-a/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   4.248 ++++ mpfr-3.0.0-b/acinclude.m4	2010-06-10 11:00:14.000000000 +0000
   4.249 +@@ -59,6 +59,9 @@
   4.250 + dnl sys/fpu.h - MIPS specific
   4.251 + AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
   4.252 + 
   4.253 ++dnl Check how to get `alloca'
   4.254 ++AC_FUNC_ALLOCA
   4.255 ++
   4.256 + dnl SIZE_MAX macro
   4.257 + gl_SIZE_MAX
   4.258 + 
   4.259 +diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
   4.260 +--- mpfr-3.0.0-a/configure	2010-06-10 11:00:51.000000000 +0000
   4.261 ++++ mpfr-3.0.0-b/configure	2010-06-25 13:23:05.000000000 +0000
   4.262 +@@ -783,6 +783,7 @@
   4.263 + OBJDUMP
   4.264 + DLLTOOL
   4.265 + AS
   4.266 ++ALLOCA
   4.267 + MPFR_LIBM
   4.268 + ANSI2KNR
   4.269 + U
   4.270 +@@ -5622,6 +5623,197 @@
   4.271 + done
   4.272 + 
   4.273 + 
   4.274 ++# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
   4.275 ++# for constant arguments.  Useless!
   4.276 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
   4.277 ++$as_echo_n "checking for working alloca.h... " >&6; }
   4.278 ++if test "${ac_cv_working_alloca_h+set}" = set; then :
   4.279 ++  $as_echo_n "(cached) " >&6
   4.280 ++else
   4.281 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.282 ++/* end confdefs.h.  */
   4.283 ++#include <alloca.h>
   4.284 ++int
   4.285 ++main ()
   4.286 ++{
   4.287 ++char *p = (char *) alloca (2 * sizeof (int));
   4.288 ++			  if (p) return 0;
   4.289 ++  ;
   4.290 ++  return 0;
   4.291 ++}
   4.292 ++_ACEOF
   4.293 ++if ac_fn_c_try_link "$LINENO"; then :
   4.294 ++  ac_cv_working_alloca_h=yes
   4.295 ++else
   4.296 ++  ac_cv_working_alloca_h=no
   4.297 ++fi
   4.298 ++rm -f core conftest.err conftest.$ac_objext \
   4.299 ++    conftest$ac_exeext conftest.$ac_ext
   4.300 ++fi
   4.301 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
   4.302 ++$as_echo "$ac_cv_working_alloca_h" >&6; }
   4.303 ++if test $ac_cv_working_alloca_h = yes; then
   4.304 ++
   4.305 ++$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
   4.306 ++
   4.307 ++fi
   4.308 ++
   4.309 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
   4.310 ++$as_echo_n "checking for alloca... " >&6; }
   4.311 ++if test "${ac_cv_func_alloca_works+set}" = set; then :
   4.312 ++  $as_echo_n "(cached) " >&6
   4.313 ++else
   4.314 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.315 ++/* end confdefs.h.  */
   4.316 ++#ifdef __GNUC__
   4.317 ++# define alloca __builtin_alloca
   4.318 ++#else
   4.319 ++# ifdef _MSC_VER
   4.320 ++#  include <malloc.h>
   4.321 ++#  define alloca _alloca
   4.322 ++# else
   4.323 ++#  ifdef HAVE_ALLOCA_H
   4.324 ++#   include <alloca.h>
   4.325 ++#  else
   4.326 ++#   ifdef _AIX
   4.327 ++ #pragma alloca
   4.328 ++#   else
   4.329 ++#    ifndef alloca /* predefined by HP cc +Olibcalls */
   4.330 ++char *alloca ();
   4.331 ++#    endif
   4.332 ++#   endif
   4.333 ++#  endif
   4.334 ++# endif
   4.335 ++#endif
   4.336 ++
   4.337 ++int
   4.338 ++main ()
   4.339 ++{
   4.340 ++char *p = (char *) alloca (1);
   4.341 ++				    if (p) return 0;
   4.342 ++  ;
   4.343 ++  return 0;
   4.344 ++}
   4.345 ++_ACEOF
   4.346 ++if ac_fn_c_try_link "$LINENO"; then :
   4.347 ++  ac_cv_func_alloca_works=yes
   4.348 ++else
   4.349 ++  ac_cv_func_alloca_works=no
   4.350 ++fi
   4.351 ++rm -f core conftest.err conftest.$ac_objext \
   4.352 ++    conftest$ac_exeext conftest.$ac_ext
   4.353 ++fi
   4.354 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
   4.355 ++$as_echo "$ac_cv_func_alloca_works" >&6; }
   4.356 ++
   4.357 ++if test $ac_cv_func_alloca_works = yes; then
   4.358 ++
   4.359 ++$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
   4.360 ++
   4.361 ++else
   4.362 ++  # The SVR3 libPW and SVR4 libucb both contain incompatible functions
   4.363 ++# that cause trouble.  Some versions do not even contain alloca or
   4.364 ++# contain a buggy version.  If you still want to use their alloca,
   4.365 ++# use ar to extract alloca.o from them instead of compiling alloca.c.
   4.366 ++
   4.367 ++ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
   4.368 ++
   4.369 ++$as_echo "#define C_ALLOCA 1" >>confdefs.h
   4.370 ++
   4.371 ++
   4.372 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
   4.373 ++$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
   4.374 ++if test "${ac_cv_os_cray+set}" = set; then :
   4.375 ++  $as_echo_n "(cached) " >&6
   4.376 ++else
   4.377 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.378 ++/* end confdefs.h.  */
   4.379 ++#if defined CRAY && ! defined CRAY2
   4.380 ++webecray
   4.381 ++#else
   4.382 ++wenotbecray
   4.383 ++#endif
   4.384 ++
   4.385 ++_ACEOF
   4.386 ++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
   4.387 ++  $EGREP "webecray" >/dev/null 2>&1; then :
   4.388 ++  ac_cv_os_cray=yes
   4.389 ++else
   4.390 ++  ac_cv_os_cray=no
   4.391 ++fi
   4.392 ++rm -f conftest*
   4.393 ++
   4.394 ++fi
   4.395 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
   4.396 ++$as_echo "$ac_cv_os_cray" >&6; }
   4.397 ++if test $ac_cv_os_cray = yes; then
   4.398 ++  for ac_func in _getb67 GETB67 getb67; do
   4.399 ++    as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
   4.400 ++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
   4.401 ++eval as_val=\$$as_ac_var
   4.402 ++   if test "x$as_val" = x""yes; then :
   4.403 ++
   4.404 ++cat >>confdefs.h <<_ACEOF
   4.405 ++#define CRAY_STACKSEG_END $ac_func
   4.406 ++_ACEOF
   4.407 ++
   4.408 ++    break
   4.409 ++fi
   4.410 ++
   4.411 ++  done
   4.412 ++fi
   4.413 ++
   4.414 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
   4.415 ++$as_echo_n "checking stack direction for C alloca... " >&6; }
   4.416 ++if test "${ac_cv_c_stack_direction+set}" = set; then :
   4.417 ++  $as_echo_n "(cached) " >&6
   4.418 ++else
   4.419 ++  if test "$cross_compiling" = yes; then :
   4.420 ++  ac_cv_c_stack_direction=0
   4.421 ++else
   4.422 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
   4.423 ++/* end confdefs.h.  */
   4.424 ++$ac_includes_default
   4.425 ++int
   4.426 ++find_stack_direction ()
   4.427 ++{
   4.428 ++  static char *addr = 0;
   4.429 ++  auto char dummy;
   4.430 ++  if (addr == 0)
   4.431 ++    {
   4.432 ++      addr = &dummy;
   4.433 ++      return find_stack_direction ();
   4.434 ++    }
   4.435 ++  else
   4.436 ++    return (&dummy > addr) ? 1 : -1;
   4.437 ++}
   4.438 ++
   4.439 ++int
   4.440 ++main ()
   4.441 ++{
   4.442 ++  return find_stack_direction () < 0;
   4.443 ++}
   4.444 ++_ACEOF
   4.445 ++if ac_fn_c_try_run "$LINENO"; then :
   4.446 ++  ac_cv_c_stack_direction=1
   4.447 ++else
   4.448 ++  ac_cv_c_stack_direction=-1
   4.449 ++fi
   4.450 ++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
   4.451 ++  conftest.$ac_objext conftest.beam conftest.$ac_ext
   4.452 ++fi
   4.453 ++
   4.454 ++fi
   4.455 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
   4.456 ++$as_echo "$ac_cv_c_stack_direction" >&6; }
   4.457 ++cat >>confdefs.h <<_ACEOF
   4.458 ++#define STACK_DIRECTION $ac_cv_c_stack_direction
   4.459 ++_ACEOF
   4.460 ++
   4.461 ++
   4.462 ++fi
   4.463 ++
   4.464 ++
   4.465 + 
   4.466 +   for ac_header in stdint.h
   4.467 + do :
   4.468 +@@ -7564,13 +7756,13 @@
   4.469 + else
   4.470 +   lt_cv_nm_interface="BSD nm"
   4.471 +   echo "int some_variable = 0;" > conftest.$ac_ext
   4.472 +-  (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
   4.473 ++  (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
   4.474 +   (eval "$ac_compile" 2>conftest.err)
   4.475 +   cat conftest.err >&5
   4.476 +-  (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   4.477 ++  (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
   4.478 +   (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
   4.479 +   cat conftest.err >&5
   4.480 +-  (eval echo "\"\$as_me:7573: output\"" >&5)
   4.481 ++  (eval echo "\"\$as_me:7765: output\"" >&5)
   4.482 +   cat conftest.out >&5
   4.483 +   if $GREP 'External.*some_variable' conftest.out > /dev/null; then
   4.484 +     lt_cv_nm_interface="MS dumpbin"
   4.485 +@@ -8772,7 +8964,7 @@
   4.486 +   ;;
   4.487 + *-*-irix6*)
   4.488 +   # Find out which ABI we are using.
   4.489 +-  echo '#line 8775 "configure"' > conftest.$ac_ext
   4.490 ++  echo '#line 8967 "configure"' > conftest.$ac_ext
   4.491 +   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
   4.492 +   (eval $ac_compile) 2>&5
   4.493 +   ac_status=$?
   4.494 +@@ -10032,11 +10224,11 @@
   4.495 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   4.496 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   4.497 +    -e 's:$: $lt_compiler_flag:'`
   4.498 +-   (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
   4.499 ++   (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
   4.500 +    (eval "$lt_compile" 2>conftest.err)
   4.501 +    ac_status=$?
   4.502 +    cat conftest.err >&5
   4.503 +-   echo "$as_me:10039: \$? = $ac_status" >&5
   4.504 ++   echo "$as_me:10231: \$? = $ac_status" >&5
   4.505 +    if (exit $ac_status) && test -s "$ac_outfile"; then
   4.506 +      # The compiler can only warn and ignore the option if not recognized
   4.507 +      # So say no if there are warnings other than the usual output.
   4.508 +@@ -10371,11 +10563,11 @@
   4.509 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   4.510 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   4.511 +    -e 's:$: $lt_compiler_flag:'`
   4.512 +-   (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
   4.513 ++   (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
   4.514 +    (eval "$lt_compile" 2>conftest.err)
   4.515 +    ac_status=$?
   4.516 +    cat conftest.err >&5
   4.517 +-   echo "$as_me:10378: \$? = $ac_status" >&5
   4.518 ++   echo "$as_me:10570: \$? = $ac_status" >&5
   4.519 +    if (exit $ac_status) && test -s "$ac_outfile"; then
   4.520 +      # The compiler can only warn and ignore the option if not recognized
   4.521 +      # So say no if there are warnings other than the usual output.
   4.522 +@@ -10476,11 +10668,11 @@
   4.523 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   4.524 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   4.525 +    -e 's:$: $lt_compiler_flag:'`
   4.526 +-   (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
   4.527 ++   (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
   4.528 +    (eval "$lt_compile" 2>out/conftest.err)
   4.529 +    ac_status=$?
   4.530 +    cat out/conftest.err >&5
   4.531 +-   echo "$as_me:10483: \$? = $ac_status" >&5
   4.532 ++   echo "$as_me:10675: \$? = $ac_status" >&5
   4.533 +    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   4.534 +    then
   4.535 +      # The compiler can only warn and ignore the option if not recognized
   4.536 +@@ -10531,11 +10723,11 @@
   4.537 +    -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
   4.538 +    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
   4.539 +    -e 's:$: $lt_compiler_flag:'`
   4.540 +-   (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
   4.541 ++   (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
   4.542 +    (eval "$lt_compile" 2>out/conftest.err)
   4.543 +    ac_status=$?
   4.544 +    cat out/conftest.err >&5
   4.545 +-   echo "$as_me:10538: \$? = $ac_status" >&5
   4.546 ++   echo "$as_me:10730: \$? = $ac_status" >&5
   4.547 +    if (exit $ac_status) && test -s out/conftest2.$ac_objext
   4.548 +    then
   4.549 +      # The compiler can only warn and ignore the option if not recognized
   4.550 +@@ -12915,7 +13107,7 @@
   4.551 +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   4.552 +   lt_status=$lt_dlunknown
   4.553 +   cat > conftest.$ac_ext <<_LT_EOF
   4.554 +-#line 12918 "configure"
   4.555 ++#line 13110 "configure"
   4.556 + #include "confdefs.h"
   4.557 + 
   4.558 + #if HAVE_DLFCN_H
   4.559 +@@ -13011,7 +13203,7 @@
   4.560 +   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   4.561 +   lt_status=$lt_dlunknown
   4.562 +   cat > conftest.$ac_ext <<_LT_EOF
   4.563 +-#line 13014 "configure"
   4.564 ++#line 13206 "configure"
   4.565 + #include "confdefs.h"
   4.566 + 
   4.567 + #if HAVE_DLFCN_H
   4.568 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   4.569 +--- mpfr-3.0.0-a/mpfr.h	2010-06-23 11:03:20.000000000 +0000
   4.570 ++++ mpfr-3.0.0-b/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   4.571 +@@ -27,7 +27,7 @@
   4.572 + #define MPFR_VERSION_MAJOR 3
   4.573 + #define MPFR_VERSION_MINOR 0
   4.574 + #define MPFR_VERSION_PATCHLEVEL 0
   4.575 +-#define MPFR_VERSION_STRING "3.0.0-p1"
   4.576 ++#define MPFR_VERSION_STRING "3.0.0-p2"
   4.577 + 
   4.578 + /* Macros dealing with MPFR VERSION */
   4.579 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.580 +diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
   4.581 +--- mpfr-3.0.0-a/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   4.582 ++++ mpfr-3.0.0-b/tests/Makefile.in	2010-06-10 11:00:52.000000000 +0000
   4.583 +@@ -960,6 +960,7 @@
   4.584 + red=; grn=; lgn=; blu=; std=
   4.585 + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
   4.586 + ACLOCAL = @ACLOCAL@
   4.587 ++ALLOCA = @ALLOCA@
   4.588 + AMTAR = @AMTAR@
   4.589 + AR = @AR@
   4.590 + AS = @AS@
   4.591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   4.592 +--- mpfr-3.0.0-a/version.c	2010-06-23 11:03:20.000000000 +0000
   4.593 ++++ mpfr-3.0.0-b/version.c	2010-06-25 13:23:13.000000000 +0000
   4.594 +@@ -25,5 +25,5 @@
   4.595 + const char *
   4.596 + mpfr_get_version (void)
   4.597 + {
   4.598 +-  return "3.0.0-p1";
   4.599 ++  return "3.0.0-p2";
   4.600 + }
   4.601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   4.602 +--- mpfr-3.0.0-a/PATCHES	2010-07-10 00:11:19.000000000 +0000
   4.603 ++++ mpfr-3.0.0-b/PATCHES	2010-07-10 00:12:50.000000000 +0000
   4.604 +@@ -0,0 +1 @@
   4.605 ++gamma_underflow
   4.606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   4.607 +--- mpfr-3.0.0-a/VERSION	2010-06-25 13:23:13.000000000 +0000
   4.608 ++++ mpfr-3.0.0-b/VERSION	2010-07-10 00:11:53.000000000 +0000
   4.609 +@@ -1 +1 @@
   4.610 +-3.0.0-p2
   4.611 ++3.0.0-p3
   4.612 +diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
   4.613 +--- mpfr-3.0.0-a/gamma.c	2010-06-10 11:00:14.000000000 +0000
   4.614 ++++ mpfr-3.0.0-b/gamma.c	2010-07-10 00:11:46.000000000 +0000
   4.615 +@@ -274,7 +274,7 @@
   4.616 +       /* we want an upper bound for x * [log(2-x)-1].
   4.617 +          since x < 0, we need a lower bound on log(2-x) */
   4.618 +       mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
   4.619 +-      mpfr_log (xp, xp, MPFR_RNDD);
   4.620 ++      mpfr_log2 (xp, xp, MPFR_RNDD);
   4.621 +       mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
   4.622 +       mpfr_mul (xp, xp, x, MPFR_RNDU);
   4.623 + 
   4.624 +@@ -303,8 +303,8 @@
   4.625 +         {
   4.626 +           mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
   4.627 +           mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
   4.628 +-          mpfr_log (tmp, tmp, MPFR_RNDU);
   4.629 +-          mpfr_add (tmp, tmp, xp, MPFR_RNDU);
   4.630 ++          mpfr_log2 (tmp, tmp, MPFR_RNDU);
   4.631 ++          mpfr_add (xp, tmp, xp, MPFR_RNDU);
   4.632 +           underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
   4.633 +         }
   4.634 + 
   4.635 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   4.636 +--- mpfr-3.0.0-a/mpfr.h	2010-06-25 13:23:13.000000000 +0000
   4.637 ++++ mpfr-3.0.0-b/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   4.638 +@@ -27,7 +27,7 @@
   4.639 + #define MPFR_VERSION_MAJOR 3
   4.640 + #define MPFR_VERSION_MINOR 0
   4.641 + #define MPFR_VERSION_PATCHLEVEL 0
   4.642 +-#define MPFR_VERSION_STRING "3.0.0-p2"
   4.643 ++#define MPFR_VERSION_STRING "3.0.0-p3"
   4.644 + 
   4.645 + /* Macros dealing with MPFR VERSION */
   4.646 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.647 +diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
   4.648 +--- mpfr-3.0.0-a/tests/tgamma.c	2010-06-10 11:00:13.000000000 +0000
   4.649 ++++ mpfr-3.0.0-b/tests/tgamma.c	2010-07-10 00:11:46.000000000 +0000
   4.650 +@@ -461,6 +461,20 @@
   4.651 +   mpfr_clear (x);
   4.652 + }
   4.653 + 
   4.654 ++/* bug found by Stathis, only occurs on 32-bit machines */
   4.655 ++static void
   4.656 ++test20100709 (void)
   4.657 ++{
   4.658 ++  mpfr_t x;
   4.659 ++  int inex;
   4.660 ++
   4.661 ++  mpfr_init2 (x, 100);
   4.662 ++  mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
   4.663 ++  inex = mpfr_gamma (x, x, MPFR_RNDN);
   4.664 ++  MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
   4.665 ++  mpfr_clear (x);
   4.666 ++}
   4.667 ++
   4.668 + int
   4.669 + main (int argc, char *argv[])
   4.670 + {
   4.671 +@@ -471,6 +485,7 @@
   4.672 +   test_generic (2, 100, 2);
   4.673 +   gamma_integer ();
   4.674 +   test20071231 ();
   4.675 ++  test20100709 ();
   4.676 + 
   4.677 +   data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
   4.678 + 
   4.679 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   4.680 +--- mpfr-3.0.0-a/version.c	2010-06-25 13:23:13.000000000 +0000
   4.681 ++++ mpfr-3.0.0-b/version.c	2010-07-10 00:11:53.000000000 +0000
   4.682 +@@ -25,5 +25,5 @@
   4.683 + const char *
   4.684 + mpfr_get_version (void)
   4.685 + {
   4.686 +-  return "3.0.0-p2";
   4.687 ++  return "3.0.0-p3";
   4.688 + }
   4.689 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   4.690 +--- mpfr-3.0.0-a/PATCHES	2010-09-07 08:44:01.000000000 +0000
   4.691 ++++ mpfr-3.0.0-b/PATCHES	2010-09-07 08:48:46.000000000 +0000
   4.692 +@@ -0,0 +1 @@
   4.693 ++mpfr_cmp/set_ui/si
   4.694 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   4.695 +--- mpfr-3.0.0-a/VERSION	2010-07-10 00:11:53.000000000 +0000
   4.696 ++++ mpfr-3.0.0-b/VERSION	2010-09-07 08:46:06.000000000 +0000
   4.697 +@@ -1 +1 @@
   4.698 +-3.0.0-p3
   4.699 ++3.0.0-p4
   4.700 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   4.701 +--- mpfr-3.0.0-a/mpfr.h	2010-07-10 00:11:53.000000000 +0000
   4.702 ++++ mpfr-3.0.0-b/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   4.703 +@@ -27,7 +27,7 @@
   4.704 + #define MPFR_VERSION_MAJOR 3
   4.705 + #define MPFR_VERSION_MINOR 0
   4.706 + #define MPFR_VERSION_PATCHLEVEL 0
   4.707 +-#define MPFR_VERSION_STRING "3.0.0-p3"
   4.708 ++#define MPFR_VERSION_STRING "3.0.0-p4"
   4.709 + 
   4.710 + /* Macros dealing with MPFR VERSION */
   4.711 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.712 +@@ -798,35 +798,45 @@
   4.713 +      anyway. Checking with other ICC versions is needed. Possibly detect
   4.714 +      whether warnings are produced or not with a configure test.
   4.715 +    + Remove C++ too, since it complains too much. */
   4.716 ++/* Added casts to improve robustness in case of undefined behavior and
   4.717 ++   compiler extensions based on UB (in particular -fwrapv). MPFR doesn't
   4.718 ++   use such extensions, but these macros will be used by 3rd-party code,
   4.719 ++   where such extensions may be required.
   4.720 ++   Moreover casts to unsigned long have been added to avoid warnings in
   4.721 ++   programs that use MPFR and are compiled with -Wconversion; such casts
   4.722 ++   are OK since if X is a constant expression, then (unsigned long) X is
   4.723 ++   also a constant expression, so that the optimizations still work. */
   4.724 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
   4.725 + #if (__GNUC__ >= 2)
   4.726 + #undef mpfr_cmp_ui
   4.727 +-/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0. */
   4.728 +-#define mpfr_cmp_ui(_f,_u)                 \
   4.729 +- (__builtin_constant_p (_u) && (_u) == 0 ? \
   4.730 +-   mpfr_sgn (_f) :                         \
   4.731 +-   mpfr_cmp_ui_2exp ((_f),(_u),0))
   4.732 ++/* We use the fact that mpfr_sgn on NaN sets the erange flag and returns 0.
   4.733 ++   But warning! mpfr_sgn is specified as a macro in the API, thus the macro
   4.734 ++   mustn't be used if side effects are possible, like here. */
   4.735 ++#define mpfr_cmp_ui(_f,_u)                                      \
   4.736 ++  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   4.737 ++   (mpfr_sgn) (_f) :                                            \
   4.738 ++   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
   4.739 + #undef mpfr_cmp_si
   4.740 +-#define mpfr_cmp_si(_f,_s)                 \
   4.741 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   4.742 +-   mpfr_cmp_ui ((_f), (_s)) :              \
   4.743 +-   mpfr_cmp_si_2exp ((_f), (_s), 0))
   4.744 ++#define mpfr_cmp_si(_f,_s)                              \
   4.745 ++  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
   4.746 ++   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
   4.747 ++   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
   4.748 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
   4.749 + #undef mpfr_set_ui
   4.750 +-#define mpfr_set_ui(_f,_u,_r)              \
   4.751 +- (__builtin_constant_p (_u) && (_u) == 0 ? \
   4.752 +-   __extension__ ({                        \
   4.753 +-     mpfr_ptr _p = (_f);                   \
   4.754 +-     _p->_mpfr_sign = 1;                   \
   4.755 +-     _p->_mpfr_exp = __MPFR_EXP_ZERO;      \
   4.756 +-     (void) (_r); 0; }) :                  \
   4.757 +-   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
   4.758 ++#define mpfr_set_ui(_f,_u,_r)                                   \
   4.759 ++  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
   4.760 ++   __extension__ ({                                             \
   4.761 ++       mpfr_ptr _p = (_f);                                      \
   4.762 ++       _p->_mpfr_sign = 1;                                      \
   4.763 ++       _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
   4.764 ++       (void) (_r); 0; }) :                                     \
   4.765 ++   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
   4.766 + #endif
   4.767 + #undef mpfr_set_si
   4.768 +-#define mpfr_set_si(_f,_s,_r)              \
   4.769 +- (__builtin_constant_p (_s) && (_s) >= 0 ? \
   4.770 +-   mpfr_set_ui ((_f), (_s), (_r)) :        \
   4.771 +-   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
   4.772 ++#define mpfr_set_si(_f,_s,_r)                                   \
   4.773 ++  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
   4.774 ++   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
   4.775 ++   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
   4.776 + #endif
   4.777 + #endif
   4.778 + 
   4.779 +diff -Naurd mpfr-3.0.0-a/tests/tcmp_ui.c mpfr-3.0.0-b/tests/tcmp_ui.c
   4.780 +--- mpfr-3.0.0-a/tests/tcmp_ui.c	2010-06-10 11:00:13.000000000 +0000
   4.781 ++++ mpfr-3.0.0-b/tests/tcmp_ui.c	2010-09-07 08:45:12.000000000 +0000
   4.782 +@@ -88,6 +88,126 @@
   4.783 +   mpfr_clear (x);
   4.784 + }
   4.785 + 
   4.786 ++/* Since mpfr_cmp_ui and mpfr_cmp_si are also implemented by a macro
   4.787 ++   with __builtin_constant_p for GCC, check that side effects are
   4.788 ++   handled correctly. */
   4.789 ++static void
   4.790 ++check_macros (void)
   4.791 ++{
   4.792 ++  mpfr_t x;
   4.793 ++  int c;
   4.794 ++
   4.795 ++  mpfr_init2 (x, 32);
   4.796 ++
   4.797 ++  c = 0;
   4.798 ++  mpfr_set_ui (x, 17, MPFR_RNDN);
   4.799 ++  if (mpfr_cmp_ui (x, 17) != 0)
   4.800 ++    {
   4.801 ++      printf ("Error 1 on mpfr_cmp_ui(x,17) in check_macros\n");
   4.802 ++      exit (1);
   4.803 ++    }
   4.804 ++  if (mpfr_cmp_ui (x, (c++, 17)) != 0)
   4.805 ++    {
   4.806 ++      printf ("Error 2 on mpfr_cmp_ui(x,17) in check_macros\n");
   4.807 ++      exit (1);
   4.808 ++    }
   4.809 ++  if (c != 1)
   4.810 ++    {
   4.811 ++      printf ("Error 3 on mpfr_cmp_ui(x,17) in check_macros\n"
   4.812 ++              "(c = %d instead of 1)\n", c);
   4.813 ++      exit (1);
   4.814 ++    }
   4.815 ++  if (mpfr_cmp_si (x, 17) != 0)
   4.816 ++    {
   4.817 ++      printf ("Error 1 on mpfr_cmp_si(x,17) in check_macros\n");
   4.818 ++      exit (1);
   4.819 ++    }
   4.820 ++  if (mpfr_cmp_si (x, (c++, 17)) != 0)
   4.821 ++    {
   4.822 ++      printf ("Error 2 on mpfr_cmp_si(x,17) in check_macros\n");
   4.823 ++      exit (1);
   4.824 ++    }
   4.825 ++  if (c != 2)
   4.826 ++    {
   4.827 ++      printf ("Error 3 on mpfr_cmp_si(x,17) in check_macros\n"
   4.828 ++              "(c = %d instead of 2)\n", c);
   4.829 ++      exit (1);
   4.830 ++    }
   4.831 ++
   4.832 ++  c = 0;
   4.833 ++  mpfr_set_ui (x, 0, MPFR_RNDN);
   4.834 ++  if (mpfr_cmp_ui (x, 0) != 0)
   4.835 ++    {
   4.836 ++      printf ("Error 1 on mpfr_cmp_ui(x,0) in check_macros\n");
   4.837 ++      exit (1);
   4.838 ++    }
   4.839 ++  if (mpfr_cmp_ui (x, (c++, 0)) != 0)
   4.840 ++    {
   4.841 ++      printf ("Error 2 on mpfr_cmp_ui(x,0) in check_macros\n");
   4.842 ++      exit (1);
   4.843 ++    }
   4.844 ++  if (c != 1)
   4.845 ++    {
   4.846 ++      printf ("Error 3 on mpfr_cmp_ui(x,0) in check_macros\n"
   4.847 ++              "(c = %d instead of 1)\n", c);
   4.848 ++      exit (1);
   4.849 ++    }
   4.850 ++  if (mpfr_cmp_si (x, 0) != 0)
   4.851 ++    {
   4.852 ++      printf ("Error 1 on mpfr_cmp_si(x,0) in check_macros\n");
   4.853 ++      exit (1);
   4.854 ++    }
   4.855 ++  if (mpfr_cmp_si (x, (c++, 0)) != 0)
   4.856 ++    {
   4.857 ++      printf ("Error 2 on mpfr_cmp_si(x,0) in check_macros\n");
   4.858 ++      exit (1);
   4.859 ++    }
   4.860 ++  if (c != 2)
   4.861 ++    {
   4.862 ++      printf ("Error 3 on mpfr_cmp_si(x,0) in check_macros\n"
   4.863 ++              "(c = %d instead of 2)\n", c);
   4.864 ++      exit (1);
   4.865 ++    }
   4.866 ++
   4.867 ++  mpfr_clear (x);
   4.868 ++}
   4.869 ++
   4.870 ++/* Bug in r7114 */
   4.871 ++static void
   4.872 ++test_macros (void)
   4.873 ++{
   4.874 ++  mpfr_t x[3];
   4.875 ++  mpfr_ptr p;
   4.876 ++
   4.877 ++  mpfr_inits (x[0], x[1], x[2], (mpfr_ptr) 0);
   4.878 ++  mpfr_set_ui (x[0], 0, MPFR_RNDN);
   4.879 ++  p = x[0];
   4.880 ++  if (mpfr_cmp_ui (p++, 0) != 0)
   4.881 ++    {
   4.882 ++      printf ("Error in mpfr_cmp_ui macro: result should be 0.\n");
   4.883 ++      exit (1);
   4.884 ++    }
   4.885 ++  if (p != x[1])
   4.886 ++    {
   4.887 ++      printf ("Error in mpfr_cmp_ui macro: p - x[0] = %d (expecting 1)\n",
   4.888 ++              (int) (p - x[0]));
   4.889 ++      exit (1);
   4.890 ++    }
   4.891 ++  p = x[0];
   4.892 ++  if (mpfr_cmp_si (p++, 0) != 0)
   4.893 ++    {
   4.894 ++      printf ("Error in mpfr_cmp_si macro: result should be 0.\n");
   4.895 ++      exit (1);
   4.896 ++    }
   4.897 ++  if (p != x[1])
   4.898 ++    {
   4.899 ++      printf ("Error in mpfr_cmp_si macro: p - x[0] = %d (expecting 1)\n",
   4.900 ++              (int) (p - x[0]));
   4.901 ++      exit (1);
   4.902 ++    }
   4.903 ++  mpfr_clears (x[0], x[1], x[2], (mpfr_ptr) 0);
   4.904 ++}
   4.905 ++
   4.906 + int
   4.907 + main (void)
   4.908 + {
   4.909 +@@ -216,6 +336,8 @@
   4.910 +   mpfr_clear (x);
   4.911 + 
   4.912 +   check_nan ();
   4.913 ++  check_macros ();
   4.914 ++  test_macros ();
   4.915 + 
   4.916 +   tests_end_mpfr ();
   4.917 +   return 0;
   4.918 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   4.919 +--- mpfr-3.0.0-a/version.c	2010-07-10 00:11:53.000000000 +0000
   4.920 ++++ mpfr-3.0.0-b/version.c	2010-09-07 08:46:06.000000000 +0000
   4.921 +@@ -25,5 +25,5 @@
   4.922 + const char *
   4.923 + mpfr_get_version (void)
   4.924 + {
   4.925 +-  return "3.0.0-p3";
   4.926 ++  return "3.0.0-p4";
   4.927 + }
   4.928 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   4.929 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 20:28:38.000000000 +0000
   4.930 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:28:38.000000000 +0000
   4.931 +@@ -0,0 +1 @@
   4.932 ++tcan_round
   4.933 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   4.934 +--- mpfr-3.0.0-a/VERSION	2010-09-07 08:46:06.000000000 +0000
   4.935 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 20:28:38.000000000 +0000
   4.936 +@@ -1 +1 @@
   4.937 +-3.0.0-p4
   4.938 ++3.0.0-p5
   4.939 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   4.940 +--- mpfr-3.0.0-a/mpfr.h	2010-09-07 08:46:06.000000000 +0000
   4.941 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   4.942 +@@ -27,7 +27,7 @@
   4.943 + #define MPFR_VERSION_MAJOR 3
   4.944 + #define MPFR_VERSION_MINOR 0
   4.945 + #define MPFR_VERSION_PATCHLEVEL 0
   4.946 +-#define MPFR_VERSION_STRING "3.0.0-p4"
   4.947 ++#define MPFR_VERSION_STRING "3.0.0-p5"
   4.948 + 
   4.949 + /* Macros dealing with MPFR VERSION */
   4.950 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.951 +diff -Naurd mpfr-3.0.0-a/tests/tcan_round.c mpfr-3.0.0-b/tests/tcan_round.c
   4.952 +--- mpfr-3.0.0-a/tests/tcan_round.c	2010-06-10 11:00:13.000000000 +0000
   4.953 ++++ mpfr-3.0.0-b/tests/tcan_round.c	2010-10-21 20:28:38.000000000 +0000
   4.954 +@@ -41,7 +41,7 @@
   4.955 +       /* avoid mpn_random which leaks memory */
   4.956 +       for (i = 0; i < n; i++)
   4.957 +         buf[i] = randlimb ();
   4.958 +-      p = (mpfr_prec_t) randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   4.959 ++      p = randlimb() % ((n-1) * GMP_NUMB_BITS) + MPFR_PREC_MIN;
   4.960 +       err = p + randlimb () % GMP_NUMB_BITS;
   4.961 +       r1 = mpfr_round_p (buf, n, err, p);
   4.962 +       r2 = mpfr_can_round_raw (buf, n, MPFR_SIGN_POS, err,
   4.963 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
   4.964 +--- mpfr-3.0.0-a/version.c	2010-09-07 08:46:06.000000000 +0000
   4.965 ++++ mpfr-3.0.0-b/version.c	2010-10-21 20:28:38.000000000 +0000
   4.966 +@@ -25,5 +25,5 @@
   4.967 + const char *
   4.968 + mpfr_get_version (void)
   4.969 + {
   4.970 +-  return "3.0.0-p4";
   4.971 ++  return "3.0.0-p5";
   4.972 + }
   4.973 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
   4.974 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 20:59:32.000000000 +0000
   4.975 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 20:59:32.000000000 +0000
   4.976 +@@ -0,0 +1 @@
   4.977 ++mpfr_sub1
   4.978 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
   4.979 +--- mpfr-3.0.0-a/VERSION	2010-10-21 20:28:38.000000000 +0000
   4.980 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 20:59:32.000000000 +0000
   4.981 +@@ -1 +1 @@
   4.982 +-3.0.0-p5
   4.983 ++3.0.0-p6
   4.984 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
   4.985 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:28:38.000000000 +0000
   4.986 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 20:59:32.000000000 +0000
   4.987 +@@ -27,7 +27,7 @@
   4.988 + #define MPFR_VERSION_MAJOR 3
   4.989 + #define MPFR_VERSION_MINOR 0
   4.990 + #define MPFR_VERSION_PATCHLEVEL 0
   4.991 +-#define MPFR_VERSION_STRING "3.0.0-p5"
   4.992 ++#define MPFR_VERSION_STRING "3.0.0-p6"
   4.993 + 
   4.994 + /* Macros dealing with MPFR VERSION */
   4.995 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.996 +diff -Naurd mpfr-3.0.0-a/sub1.c mpfr-3.0.0-b/sub1.c
   4.997 +--- mpfr-3.0.0-a/sub1.c	2010-06-10 11:00:14.000000000 +0000
   4.998 ++++ mpfr-3.0.0-b/sub1.c	2010-10-21 20:59:32.000000000 +0000
   4.999 +@@ -37,7 +37,9 @@
  4.1000 +   mp_size_t cancel2, an, bn, cn, cn0;
  4.1001 +   mp_limb_t *ap, *bp, *cp;
  4.1002 +   mp_limb_t carry, bb, cc, borrow = 0;
  4.1003 +-  int inexact, shift_b, shift_c, is_exact = 1, down = 0, add_exp = 0;
  4.1004 ++  int inexact, shift_b, shift_c, add_exp = 0;
  4.1005 ++  int cmp_low = 0; /* used for rounding to nearest: 0 if low(b) = low(c),
  4.1006 ++                      negative if low(b) < low(c), positive if low(b)>low(c) */
  4.1007 +   int sh, k;
  4.1008 +   MPFR_TMP_DECL(marker);
  4.1009 + 
  4.1010 +@@ -196,7 +198,8 @@
  4.1011 +     }
  4.1012 + 
  4.1013 + #ifdef DEBUG
  4.1014 +-  printf ("shift_b=%d shift_c=%d diffexp=%lu\n", shift_b, shift_c,
  4.1015 ++  printf ("rnd=%s shift_b=%d shift_c=%d diffexp=%lu\n",
  4.1016 ++          mpfr_print_rnd_mode (rnd_mode), shift_b, shift_c,
  4.1017 +           (unsigned long) diff_exp);
  4.1018 + #endif
  4.1019 + 
  4.1020 +@@ -307,17 +310,18 @@
  4.1021 +     {
  4.1022 +       if (MPFR_LIKELY(sh))
  4.1023 +         {
  4.1024 +-          is_exact = (carry == 0);
  4.1025 +           /* can decide except when carry = 2^(sh-1) [middle]
  4.1026 +              or carry = 0 [truncate, but cannot decide inexact flag] */
  4.1027 +-          down = (carry < (MPFR_LIMB_ONE << (sh - 1)));
  4.1028 +           if (carry > (MPFR_LIMB_ONE << (sh - 1)))
  4.1029 +             goto add_one_ulp;
  4.1030 +-          else if ((0 < carry) && down)
  4.1031 ++          else if ((0 < carry) && (carry < (MPFR_LIMB_ONE << (sh - 1))))
  4.1032 +             {
  4.1033 +               inexact = -1; /* result if smaller than exact value */
  4.1034 +               goto truncate;
  4.1035 +             }
  4.1036 ++          /* now carry = 2^(sh-1), in which case cmp_low=2,
  4.1037 ++             or carry = 0, in which case cmp_low=0 */
  4.1038 ++          cmp_low = (carry == 0) ? 0 : 2;
  4.1039 +         }
  4.1040 +     }
  4.1041 +   else /* directed rounding: set rnd_mode to RNDZ iff toward zero */
  4.1042 +@@ -344,12 +348,32 @@
  4.1043 +   cn -= (long int) an + cancel2;
  4.1044 + 
  4.1045 + #ifdef DEBUG
  4.1046 +-  printf ("last %d bits from a are %lu, bn=%ld, cn=%ld\n",
  4.1047 ++  printf ("last sh=%d bits from a are %lu, bn=%ld, cn=%ld\n",
  4.1048 +           sh, (unsigned long) carry, (long) bn, (long) cn);
  4.1049 + #endif
  4.1050 + 
  4.1051 ++  /* for rounding to nearest, we couldn't conclude up to here in the following
  4.1052 ++     cases:
  4.1053 ++     1. sh = 0, then cmp_low=0: we can either truncate, subtract one ulp
  4.1054 ++        or add one ulp: -1 ulp < low(b)-low(c) < 1 ulp
  4.1055 ++     2. sh > 0 but the low sh bits from high(b)-high(c) equal 2^(sh-1):
  4.1056 ++        -0.5 ulp <= -1/2^sh < low(b)-low(c)-0.5 < 1/2^sh <= 0.5 ulp
  4.1057 ++        we can't decide the rounding, in that case cmp_low=2:
  4.1058 ++        either we truncate and flag=-1, or we add one ulp and flag=1
  4.1059 ++     3. the low sh>0 bits from high(b)-high(c) equal 0: we know we have to
  4.1060 ++        truncate but we can't decide the ternary value, here cmp_low=0:
  4.1061 ++        -0.5 ulp <= -1/2^sh < low(b)-low(c) < 1/2^sh <= 0.5 ulp
  4.1062 ++        we always truncate and inexact can be any of -1,0,1
  4.1063 ++  */
  4.1064 ++
  4.1065 ++  /* note: here cn might exceed cn0, in which case we consider a zero limb */
  4.1066 +   for (k = 0; (bn > 0) || (cn > 0); k = 1)
  4.1067 +     {
  4.1068 ++      /* if cmp_low < 0, we know low(b) - low(c) < 0
  4.1069 ++         if cmp_low > 0, we know low(b) - low(c) > 0
  4.1070 ++            (more precisely if cmp_low = 2, low(b) - low(c) = 0.5 ulp so far)
  4.1071 ++         if cmp_low = 0, so far low(b) - low(c) = 0 */
  4.1072 ++
  4.1073 +       /* get next limbs */
  4.1074 +       bb = (bn > 0) ? bp[--bn] : 0;
  4.1075 +       if ((cn > 0) && (cn-- <= cn0))
  4.1076 +@@ -357,76 +381,115 @@
  4.1077 +       else
  4.1078 +         cc = 0;
  4.1079 + 
  4.1080 +-      /* down is set when low(b) < low(c) */
  4.1081 +-      if (down == 0)
  4.1082 +-        down = (bb < cc);
  4.1083 ++      /* cmp_low compares low(b) and low(c) */
  4.1084 ++      if (cmp_low == 0) /* case 1 or 3 */
  4.1085 ++        cmp_low = (bb < cc) ? -2+k : (bb > cc) ? 1 : 0;
  4.1086 ++
  4.1087 ++      /* Case 1 for k=0 splits into 7 subcases:
  4.1088 ++         1a: bb > cc + half
  4.1089 ++         1b: bb = cc + half
  4.1090 ++         1c: 0 < bb - cc < half
  4.1091 ++         1d: bb = cc
  4.1092 ++         1e: -half < bb - cc < 0
  4.1093 ++         1f: bb - cc = -half
  4.1094 ++         1g: bb - cc < -half
  4.1095 ++
  4.1096 ++         Case 2 splits into 3 subcases:
  4.1097 ++         2a: bb > cc
  4.1098 ++         2b: bb = cc
  4.1099 ++         2c: bb < cc
  4.1100 ++
  4.1101 ++         Case 3 splits into 3 subcases:
  4.1102 ++         3a: bb > cc
  4.1103 ++         3b: bb = cc
  4.1104 ++         3c: bb < cc
  4.1105 ++      */
  4.1106 + 
  4.1107 +       /* the case rounding to nearest with sh=0 is special since one couldn't
  4.1108 +          subtract above 1/2 ulp in the trailing limb of the result */
  4.1109 +-      if ((rnd_mode == MPFR_RNDN) && sh == 0 && k == 0)
  4.1110 ++      if (rnd_mode == MPFR_RNDN && sh == 0 && k == 0) /* case 1 for k=0 */
  4.1111 +         {
  4.1112 +           mp_limb_t half = MPFR_LIMB_HIGHBIT;
  4.1113 + 
  4.1114 +-          is_exact = (bb == cc);
  4.1115 +-
  4.1116 +           /* add one ulp if bb > cc + half
  4.1117 +              truncate if cc - half < bb < cc + half
  4.1118 +              sub one ulp if bb < cc - half
  4.1119 +           */
  4.1120 + 
  4.1121 +-          if (down)
  4.1122 ++          if (cmp_low < 0) /* bb < cc: -1 ulp < low(b) - low(c) < 0,
  4.1123 ++                              cases 1e, 1f and 1g */
  4.1124 +             {
  4.1125 +               if (cc >= half)
  4.1126 +                 cc -= half;
  4.1127 +-              else
  4.1128 ++              else /* since bb < cc < half, bb+half < 2*half */
  4.1129 +                 bb += half;
  4.1130 ++              /* now we have bb < cc + half:
  4.1131 ++                 we have to subtract one ulp if bb < cc,
  4.1132 ++                 and truncate if bb > cc */
  4.1133 +             }
  4.1134 +-          else /* bb >= cc */
  4.1135 ++          else if (cmp_low >= 0) /* bb >= cc, cases 1a to 1d */
  4.1136 +             {
  4.1137 +               if (cc < half)
  4.1138 +                 cc += half;
  4.1139 +-              else
  4.1140 ++              else /* since bb >= cc >= half, bb - half >= 0 */
  4.1141 +                 bb -= half;
  4.1142 ++              /* now we have bb > cc - half: we have to add one ulp if bb > cc,
  4.1143 ++                 and truncate if bb < cc */
  4.1144 ++              if (cmp_low > 0)
  4.1145 ++                cmp_low = 2;
  4.1146 +             }
  4.1147 +         }
  4.1148 + 
  4.1149 + #ifdef DEBUG
  4.1150 +-      printf ("    bb=%lu cc=%lu down=%d is_exact=%d\n",
  4.1151 +-              (unsigned long) bb, (unsigned long) cc, down, is_exact);
  4.1152 ++      printf ("k=%u bb=%lu cc=%lu cmp_low=%d\n", k,
  4.1153 ++              (unsigned long) bb, (unsigned long) cc, cmp_low);
  4.1154 + #endif
  4.1155 +-      if (bb < cc)
  4.1156 ++      if (cmp_low < 0) /* low(b) - low(c) < 0: either truncate or subtract
  4.1157 ++                          one ulp */
  4.1158 +         {
  4.1159 +           if (rnd_mode == MPFR_RNDZ)
  4.1160 +-            goto sub_one_ulp;
  4.1161 ++            goto sub_one_ulp; /* set inexact=-1 */
  4.1162 +           else if (rnd_mode != MPFR_RNDN) /* round away */
  4.1163 +             {
  4.1164 +               inexact = 1;
  4.1165 +               goto truncate;
  4.1166 +             }
  4.1167 +-          else /* round to nearest: special case here since for sh=k=0
  4.1168 +-                  bb = bb0 - MPFR_LIMB_HIGHBIT */
  4.1169 ++          else /* round to nearest */
  4.1170 +             {
  4.1171 +-              if (is_exact && sh == 0)
  4.1172 +-                {
  4.1173 +-                  /* For k=0 we can't decide exactness since it may depend
  4.1174 +-                     from low order bits.
  4.1175 +-                     For k=1, the first low limbs matched: low(b)-low(c)<0. */
  4.1176 +-                  if (k)
  4.1177 +-                    {
  4.1178 +-                      inexact = 1;
  4.1179 +-                      goto truncate;
  4.1180 +-                    }
  4.1181 +-                }
  4.1182 +-              else if (down && sh == 0)
  4.1183 +-                goto sub_one_ulp;
  4.1184 +-              else
  4.1185 +-                {
  4.1186 +-                  inexact = (is_exact) ? 1 : -1;
  4.1187 ++              /* If cmp_low < 0 and bb > cc, then -0.5 ulp < low(b)-low(c) < 0,
  4.1188 ++                 whatever the value of sh.
  4.1189 ++                 If sh>0, then cmp_low < 0 implies that the initial neglected
  4.1190 ++                 sh bits were 0 (otherwise cmp_low=2 initially), thus the
  4.1191 ++                 weight of the new bits is less than 0.5 ulp too.
  4.1192 ++                 If k > 0 (and sh=0) this means that either the first neglected
  4.1193 ++                 limbs bb and cc were equal (thus cmp_low was 0 for k=0),
  4.1194 ++                 or we had bb - cc = -0.5 ulp or 0.5 ulp.
  4.1195 ++                 The last case is not possible here since we would have
  4.1196 ++                 cmp_low > 0 which is sticky.
  4.1197 ++                 In the first case (where we have cmp_low = -1), we truncate,
  4.1198 ++                 whereas in the 2nd case we have cmp_low = -2 and we subtract
  4.1199 ++                 one ulp.
  4.1200 ++              */
  4.1201 ++              if (bb > cc || sh > 0 || cmp_low == -1)
  4.1202 ++                {  /* -0.5 ulp < low(b)-low(c) < 0,
  4.1203 ++                      bb > cc corresponds to cases 1e and 1f1
  4.1204 ++                      sh > 0 corresponds to cases 3c and 3b3
  4.1205 ++                      cmp_low = -1 corresponds to case 1d3 (also 3b3) */
  4.1206 ++                  inexact = 1;
  4.1207 +                   goto truncate;
  4.1208 +                 }
  4.1209 ++              else if (bb < cc) /* here sh = 0 and low(b)-low(c) < -0.5 ulp,
  4.1210 ++                                   this corresponds to cases 1g and 1f3 */
  4.1211 ++                goto sub_one_ulp;
  4.1212 ++              /* the only case where we can't conclude is sh=0 and bb=cc,
  4.1213 ++                 i.e., we have low(b) - low(c) = -0.5 ulp (up to now), thus
  4.1214 ++                 we don't know if we must truncate or subtract one ulp.
  4.1215 ++                 Note: for sh=0 we can't have low(b) - low(c) = -0.5 ulp up to
  4.1216 ++                 now, since low(b) - low(c) > 1/2^sh */
  4.1217 +             }
  4.1218 +         }
  4.1219 +-      else if (bb > cc)
  4.1220 ++      else if (cmp_low > 0) /* 0 < low(b) - low(c): either truncate or
  4.1221 ++                               add one ulp */
  4.1222 +         {
  4.1223 +           if (rnd_mode == MPFR_RNDZ)
  4.1224 +             {
  4.1225 +@@ -437,34 +500,70 @@
  4.1226 +             goto add_one_ulp;
  4.1227 +           else /* round to nearest */
  4.1228 +             {
  4.1229 +-              if (is_exact)
  4.1230 ++              if (bb > cc)
  4.1231 +                 {
  4.1232 +-                  inexact = -1;
  4.1233 +-                  goto truncate;
  4.1234 ++                  /* if sh=0, then bb>cc means that low(b)-low(c) > 0.5 ulp,
  4.1235 ++                     and similarly when cmp_low=2 */
  4.1236 ++                  if (cmp_low == 2) /* cases 1a, 1b1, 2a and 2b1 */
  4.1237 ++                    goto add_one_ulp;
  4.1238 ++                  /* sh > 0 and cmp_low > 0: this implies that the sh initial
  4.1239 ++                     neglected bits were 0, and the remaining low(b)-low(c)>0,
  4.1240 ++                     but its weight is less than 0.5 ulp */
  4.1241 ++                  else /* 0 < low(b) - low(c) < 0.5 ulp, this corresponds to
  4.1242 ++                          cases 3a, 1d1 and 3b1 */
  4.1243 ++                    {
  4.1244 ++                      inexact = -1;
  4.1245 ++                      goto truncate;
  4.1246 ++                    }
  4.1247 +                 }
  4.1248 +-              else if (down)
  4.1249 ++              else if (bb < cc) /* 0 < low(b) - low(c) < 0.5 ulp, cases 1c,
  4.1250 ++                                   1b3, 2b3 and 2c */
  4.1251 +                 {
  4.1252 +-                  inexact = 1;
  4.1253 ++                  inexact = -1;
  4.1254 +                   goto truncate;
  4.1255 +                 }
  4.1256 +-              else
  4.1257 +-                goto add_one_ulp;
  4.1258 ++              /* the only case where we can't conclude is bb=cc, i.e.,
  4.1259 ++                 low(b) - low(c) = 0.5 ulp (up to now), thus we don't know
  4.1260 ++                 if we must truncate or add one ulp. */
  4.1261 +             }
  4.1262 +         }
  4.1263 ++      /* after k=0, we cannot conclude in the following cases, we split them
  4.1264 ++         according to the values of bb and cc for k=1:
  4.1265 ++         1b. sh=0 and cmp_low = 1 and bb-cc = half [around 0.5 ulp]
  4.1266 ++             1b1. bb > cc: add one ulp, inex = 1
  4.1267 ++             1b2: bb = cc: cannot conclude
  4.1268 ++             1b3: bb < cc: truncate, inex = -1
  4.1269 ++         1d. sh=0 and cmp_low = 0 and bb-cc = 0 [around 0]
  4.1270 ++             1d1: bb > cc: truncate, inex = -1
  4.1271 ++             1d2: bb = cc: cannot conclude
  4.1272 ++             1d3: bb < cc: truncate, inex = +1
  4.1273 ++         1f. sh=0 and cmp_low = -1 and bb-cc = -half [around -0.5 ulp]
  4.1274 ++             1f1: bb > cc: truncate, inex = +1
  4.1275 ++             1f2: bb = cc: cannot conclude
  4.1276 ++             1f3: bb < cc: sub one ulp, inex = -1
  4.1277 ++         2b. sh > 0 and cmp_low = 2 and bb=cc [around 0.5 ulp]
  4.1278 ++             2b1. bb > cc: add one ulp, inex = 1
  4.1279 ++             2b2: bb = cc: cannot conclude
  4.1280 ++             2b3: bb < cc: truncate, inex = -1
  4.1281 ++         3b. sh > 0 and cmp_low = 0 [around 0]
  4.1282 ++             3b1. bb > cc: truncate, inex = -1
  4.1283 ++             3b2: bb = cc: cannot conclude
  4.1284 ++             3b3: bb < cc: truncate, inex = +1
  4.1285 ++      */
  4.1286 +     }
  4.1287 + 
  4.1288 +-  if ((rnd_mode == MPFR_RNDN) && !is_exact)
  4.1289 ++  if ((rnd_mode == MPFR_RNDN) && cmp_low != 0)
  4.1290 +     {
  4.1291 +       /* even rounding rule */
  4.1292 +       if ((ap[0] >> sh) & 1)
  4.1293 +         {
  4.1294 +-          if (down)
  4.1295 ++          if (cmp_low < 0)
  4.1296 +             goto sub_one_ulp;
  4.1297 +           else
  4.1298 +             goto add_one_ulp;
  4.1299 +         }
  4.1300 +       else
  4.1301 +-        inexact = (down) ? 1 : -1;
  4.1302 ++        inexact = (cmp_low > 0) ? -1 : 1;
  4.1303 +     }
  4.1304 +   else
  4.1305 +     inexact = 0;
  4.1306 +diff -Naurd mpfr-3.0.0-a/tests/tfma.c mpfr-3.0.0-b/tests/tfma.c
  4.1307 +--- mpfr-3.0.0-a/tests/tfma.c	2010-06-10 11:00:13.000000000 +0000
  4.1308 ++++ mpfr-3.0.0-b/tests/tfma.c	2010-10-21 20:59:32.000000000 +0000
  4.1309 +@@ -337,6 +337,94 @@
  4.1310 +   mpfr_clears (x, y, z, r, (mpfr_ptr) 0);
  4.1311 + }
  4.1312 + 
  4.1313 ++static void
  4.1314 ++bug20101018 (void)
  4.1315 ++{
  4.1316 ++  mpfr_t x, y, z, t, u;
  4.1317 ++  int i;
  4.1318 ++
  4.1319 ++  mpfr_init2 (x, 64);
  4.1320 ++  mpfr_init2 (y, 64);
  4.1321 ++  mpfr_init2 (z, 64);
  4.1322 ++  mpfr_init2 (t, 64);
  4.1323 ++  mpfr_init2 (u, 64);
  4.1324 ++
  4.1325 ++  mpfr_set_str (x, "0xf.fffffffffffffffp-14766", 16, MPFR_RNDN);
  4.1326 ++  mpfr_set_str (y, "-0xf.fffffffffffffffp+317", 16, MPFR_RNDN);
  4.1327 ++  mpfr_set_str (z, "0x8.3ffffffffffe3ffp-14443", 16, MPFR_RNDN);
  4.1328 ++  mpfr_set_str (t, "0x8.7ffffffffffc7ffp-14444", 16, MPFR_RNDN);
  4.1329 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  4.1330 ++  if (mpfr_cmp (u, t) != 0)
  4.1331 ++    {
  4.1332 ++      printf ("Wrong result in bug20101018 (a)\n");
  4.1333 ++      printf ("Expected ");
  4.1334 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  4.1335 ++      printf ("\nGot      ");
  4.1336 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  4.1337 ++      printf ("\n");
  4.1338 ++      exit (1);
  4.1339 ++    }
  4.1340 ++  if (i <= 0)
  4.1341 ++    {
  4.1342 ++      printf ("Wrong ternary value in bug20101018 (a)\n");
  4.1343 ++      printf ("Expected > 0\n");
  4.1344 ++      printf ("Got      %d\n", i);
  4.1345 ++      exit (1);
  4.1346 ++    }
  4.1347 ++
  4.1348 ++  mpfr_set_str (x, "-0xf.fffffffffffffffp-11420", 16, MPFR_RNDN);
  4.1349 ++  mpfr_set_str (y, "0xf.fffffffffffffffp+9863", 16, MPFR_RNDN);
  4.1350 ++  mpfr_set_str (z, "0x8.fffff80ffffffffp-1551", 16, MPFR_RNDN);
  4.1351 ++  mpfr_set_str (t, "0x9.fffff01ffffffffp-1552", 16, MPFR_RNDN);
  4.1352 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  4.1353 ++  if (mpfr_cmp (u, t) != 0)
  4.1354 ++    {
  4.1355 ++      printf ("Wrong result in bug20101018 (b)\n");
  4.1356 ++      printf ("Expected ");
  4.1357 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  4.1358 ++      printf ("\nGot      ");
  4.1359 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  4.1360 ++      printf ("\n");
  4.1361 ++      exit (1);
  4.1362 ++    }
  4.1363 ++  if (i <= 0)
  4.1364 ++    {
  4.1365 ++      printf ("Wrong ternary value in bug20101018 (b)\n");
  4.1366 ++      printf ("Expected > 0\n");
  4.1367 ++      printf ("Got      %d\n", i);
  4.1368 ++      exit (1);
  4.1369 ++    }
  4.1370 ++
  4.1371 ++  mpfr_set_str (x, "0xf.fffffffffffffffp-2125", 16, MPFR_RNDN);
  4.1372 ++  mpfr_set_str (y, "-0xf.fffffffffffffffp-6000", 16, MPFR_RNDN);
  4.1373 ++  mpfr_set_str (z, "0x8p-8119", 16, MPFR_RNDN);
  4.1374 ++  mpfr_set_str (t, "0x8.000000000000001p-8120", 16, MPFR_RNDN);
  4.1375 ++  i = mpfr_fma (u, x, y, z, MPFR_RNDN);
  4.1376 ++  if (mpfr_cmp (u, t) != 0)
  4.1377 ++    {
  4.1378 ++      printf ("Wrong result in bug20101018 (c)\n");
  4.1379 ++      printf ("Expected ");
  4.1380 ++      mpfr_out_str (stdout, 16, 0, t, MPFR_RNDN);
  4.1381 ++      printf ("\nGot      ");
  4.1382 ++      mpfr_out_str (stdout, 16, 0, u, MPFR_RNDN);
  4.1383 ++      printf ("\n");
  4.1384 ++      exit (1);
  4.1385 ++    }
  4.1386 ++  if (i <= 0)
  4.1387 ++    {
  4.1388 ++      printf ("Wrong ternary value in bug20101018 (c)\n");
  4.1389 ++      printf ("Expected > 0\n");
  4.1390 ++      printf ("Got      %d\n", i);
  4.1391 ++      exit (1);
  4.1392 ++    }
  4.1393 ++
  4.1394 ++  mpfr_clear (x);
  4.1395 ++  mpfr_clear (y);
  4.1396 ++  mpfr_clear (z);
  4.1397 ++  mpfr_clear (t);
  4.1398 ++  mpfr_clear (u);
  4.1399 ++}
  4.1400 ++
  4.1401 + int
  4.1402 + main (int argc, char *argv[])
  4.1403 + {
  4.1404 +@@ -345,6 +433,8 @@
  4.1405 + 
  4.1406 +   tests_start_mpfr ();
  4.1407 + 
  4.1408 ++  bug20101018 ();
  4.1409 ++
  4.1410 +   mpfr_init (x);
  4.1411 +   mpfr_init (s);
  4.1412 +   mpfr_init (y);
  4.1413 +diff -Naurd mpfr-3.0.0-a/tests/tsub.c mpfr-3.0.0-b/tests/tsub.c
  4.1414 +--- mpfr-3.0.0-a/tests/tsub.c	2010-06-10 11:00:13.000000000 +0000
  4.1415 ++++ mpfr-3.0.0-b/tests/tsub.c	2010-10-21 20:59:32.000000000 +0000
  4.1416 +@@ -201,6 +201,8 @@
  4.1417 +   if (mpfr_cmp (z, x))
  4.1418 +     {
  4.1419 +       printf ("Error in mpfr_sub (2)\n");
  4.1420 ++      printf ("Expected "); mpfr_print_binary (x); puts ("");
  4.1421 ++      printf ("Got      "); mpfr_print_binary (z); puts ("");
  4.1422 +       exit (1);
  4.1423 +     }
  4.1424 +   mpfr_set_str_binary (x, "1.1110111011110001110111011111111111101000011001011100101100101101");
  4.1425 +@@ -478,6 +480,156 @@
  4.1426 +   mpfr_clear (u);
  4.1427 + }
  4.1428 + 
  4.1429 ++/* Bug found by Jakub Jelinek
  4.1430 ++ * http://bugzilla.redhat.com/643657
  4.1431 ++ * https://gforge.inria.fr/tracker/index.php?func=detail&aid=11301
  4.1432 ++ * The consequence can be either an assertion failure (i = 2 in the
  4.1433 ++ * testcase below, in debug mode) or an incorrectly rounded value.
  4.1434 ++ */
  4.1435 ++static void
  4.1436 ++bug20101017 (void)
  4.1437 ++{
  4.1438 ++  mpfr_t a, b, c;
  4.1439 ++  int inex;
  4.1440 ++  int i;
  4.1441 ++
  4.1442 ++  mpfr_init2 (a, GMP_NUMB_BITS * 2);
  4.1443 ++  mpfr_init2 (b, GMP_NUMB_BITS);
  4.1444 ++  mpfr_init2 (c, GMP_NUMB_BITS);
  4.1445 ++
  4.1446 ++  /* a = 2^(2N) + k.2^(2N-1) + 2^N and b = 1
  4.1447 ++     with N = GMP_NUMB_BITS and k = 0 or 1.
  4.1448 ++     c = a - b should round to the same value as a. */
  4.1449 ++
  4.1450 ++  for (i = 2; i <= 3; i++)
  4.1451 ++    {
  4.1452 ++      mpfr_set_ui_2exp (a, i, GMP_NUMB_BITS - 1, MPFR_RNDN);
  4.1453 ++      mpfr_add_ui (a, a, 1, MPFR_RNDN);
  4.1454 ++      mpfr_mul_2ui (a, a, GMP_NUMB_BITS, MPFR_RNDN);
  4.1455 ++      mpfr_set_ui (b, 1, MPFR_RNDN);
  4.1456 ++      inex = mpfr_sub (c, a, b, MPFR_RNDN);
  4.1457 ++      mpfr_set (b, a, MPFR_RNDN);
  4.1458 ++      if (! mpfr_equal_p (c, b))
  4.1459 ++        {
  4.1460 ++          printf ("Error in bug20101017 for i = %d.\n", i);
  4.1461 ++          printf ("Expected ");
  4.1462 ++          mpfr_out_str (stdout, 16, 0, b, MPFR_RNDN);
  4.1463 ++          putchar ('\n');
  4.1464 ++          printf ("Got      ");
  4.1465 ++          mpfr_out_str (stdout, 16, 0, c, MPFR_RNDN);
  4.1466 ++          putchar ('\n');
  4.1467 ++          exit (1);
  4.1468 ++        }
  4.1469 ++      if (inex >= 0)
  4.1470 ++        {
  4.1471 ++          printf ("Error in bug20101017 for i = %d: bad inex value.\n", i);
  4.1472 ++          printf ("Expected negative, got %d.\n", inex);
  4.1473 ++          exit (1);
  4.1474 ++        }
  4.1475 ++    }
  4.1476 ++
  4.1477 ++  mpfr_set_prec (a, 64);
  4.1478 ++  mpfr_set_prec (b, 129);
  4.1479 ++  mpfr_set_prec (c, 2);
  4.1480 ++  mpfr_set_str_binary (b, "0.100000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001E65");
  4.1481 ++  mpfr_set_str_binary (c, "0.10E1");
  4.1482 ++  inex = mpfr_sub (a, b, c, MPFR_RNDN);
  4.1483 ++  if (mpfr_cmp_ui_2exp (a, 1, 64) != 0 || inex >= 0)
  4.1484 ++    {
  4.1485 ++      printf ("Error in mpfr_sub for b-c for b=2^64+1+2^(-64), c=1\n");
  4.1486 ++      printf ("Expected result 2^64 with inex < 0\n");
  4.1487 ++      printf ("Got "); mpfr_print_binary (a);
  4.1488 ++      printf (" with inex=%d\n", inex);
  4.1489 ++      exit (1);
  4.1490 ++    }
  4.1491 ++
  4.1492 ++  mpfr_clears (a, b, c, (mpfr_ptr) 0);
  4.1493 ++}
  4.1494 ++
  4.1495 ++/* hard test of rounding */
  4.1496 ++static void
  4.1497 ++check_rounding (void)
  4.1498 ++{
  4.1499 ++  mpfr_t a, b, c, res;
  4.1500 ++  mpfr_prec_t p;
  4.1501 ++  long k, l;
  4.1502 ++  int i;
  4.1503 ++
  4.1504 ++#define MAXKL (2 * GMP_NUMB_BITS)
  4.1505 ++  for (p = MPFR_PREC_MIN; p <= GMP_NUMB_BITS; p++)
  4.1506 ++    {
  4.1507 ++      mpfr_init2 (a, p);
  4.1508 ++      mpfr_init2 (res, p);
  4.1509 ++      mpfr_init2 (b, p + 1 + MAXKL);
  4.1510 ++      mpfr_init2 (c, MPFR_PREC_MIN);
  4.1511 ++
  4.1512 ++      /* b = 2^p + 1 + 2^(-k), c = 2^(-l) */
  4.1513 ++      for (k = 0; k <= MAXKL; k++)
  4.1514 ++        for (l = 0; l <= MAXKL; l++)
  4.1515 ++          {
  4.1516 ++            mpfr_set_ui_2exp (b, 1, p, MPFR_RNDN);
  4.1517 ++            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  4.1518 ++            mpfr_mul_2ui (b, b, k, MPFR_RNDN);
  4.1519 ++            mpfr_add_ui (b, b, 1, MPFR_RNDN);
  4.1520 ++            mpfr_div_2ui (b, b, k, MPFR_RNDN);
  4.1521 ++            mpfr_set_ui_2exp (c, 1, -l, MPFR_RNDN);
  4.1522 ++            i = mpfr_sub (a, b, c, MPFR_RNDN);
  4.1523 ++            /* b - c = 2^p + 1 + 2^(-k) - 2^(-l), should be rounded to
  4.1524 ++               2^p for l <= k, and 2^p+2 for l < k */
  4.1525 ++            if (l <= k)
  4.1526 ++              {
  4.1527 ++                if (mpfr_cmp_ui_2exp (a, 1, p) != 0)
  4.1528 ++                  {
  4.1529 ++                    printf ("Wrong result in check_rounding\n");
  4.1530 ++                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  4.1531 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  4.1532 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  4.1533 ++                    printf ("Expected 2^%lu\n", p);
  4.1534 ++                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  4.1535 ++                    exit (1);
  4.1536 ++                  }
  4.1537 ++                if (i >= 0)
  4.1538 ++                  {
  4.1539 ++                    printf ("Wrong ternary value in check_rounding\n");
  4.1540 ++                    printf ("p=%lu k=%ld l=%ld\n", p, k, l);
  4.1541 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  4.1542 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  4.1543 ++                    printf ("a="); mpfr_print_binary (a); puts ("");
  4.1544 ++                    printf ("Expected < 0, got %d\n", i);
  4.1545 ++                    exit (1);
  4.1546 ++                  }
  4.1547 ++              }
  4.1548 ++            else /* l < k */
  4.1549 ++              {
  4.1550 ++                mpfr_set_ui_2exp (res, 1, p, MPFR_RNDN);
  4.1551 ++                mpfr_add_ui (res, res, 2, MPFR_RNDN);
  4.1552 ++                if (mpfr_cmp (a, res) != 0)
  4.1553 ++                  {
  4.1554 ++                    printf ("Wrong result in check_rounding\n");
  4.1555 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  4.1556 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  4.1557 ++                    printf ("Expected "); mpfr_print_binary (res); puts ("");
  4.1558 ++                    printf ("Got      "); mpfr_print_binary (a); puts ("");
  4.1559 ++                    exit (1);
  4.1560 ++                  }
  4.1561 ++                if (i <= 0)
  4.1562 ++                  {
  4.1563 ++                    printf ("Wrong ternary value in check_rounding\n");
  4.1564 ++                    printf ("b="); mpfr_print_binary (b); puts ("");
  4.1565 ++                    printf ("c="); mpfr_print_binary (c); puts ("");
  4.1566 ++                    printf ("Expected > 0, got %d\n", i);
  4.1567 ++                    exit (1);
  4.1568 ++                  }
  4.1569 ++              }
  4.1570 ++          }
  4.1571 ++
  4.1572 ++      mpfr_clear (a);
  4.1573 ++      mpfr_clear (res);
  4.1574 ++      mpfr_clear (b);
  4.1575 ++      mpfr_clear (c);
  4.1576 ++    }
  4.1577 ++}
  4.1578 ++
  4.1579 + #define TEST_FUNCTION test_sub
  4.1580 + #define TWO_ARGS
  4.1581 + #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
  4.1582 +@@ -491,6 +643,8 @@
  4.1583 + 
  4.1584 +   tests_start_mpfr ();
  4.1585 + 
  4.1586 ++  bug20101017 ();
  4.1587 ++  check_rounding ();
  4.1588 +   check_diverse ();
  4.1589 +   check_inexact ();
  4.1590 +   bug_ddefour ();
  4.1591 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  4.1592 +--- mpfr-3.0.0-a/version.c	2010-10-21 20:28:38.000000000 +0000
  4.1593 ++++ mpfr-3.0.0-b/version.c	2010-10-21 20:59:32.000000000 +0000
  4.1594 +@@ -25,5 +25,5 @@
  4.1595 + const char *
  4.1596 + mpfr_get_version (void)
  4.1597 + {
  4.1598 +-  return "3.0.0-p5";
  4.1599 ++  return "3.0.0-p6";
  4.1600 + }
  4.1601 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  4.1602 +--- mpfr-3.0.0-a/PATCHES	2010-10-21 21:18:26.000000000 +0000
  4.1603 ++++ mpfr-3.0.0-b/PATCHES	2010-10-21 21:18:26.000000000 +0000
  4.1604 +@@ -0,0 +1 @@
  4.1605 ++mpfr_set_ld
  4.1606 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  4.1607 +--- mpfr-3.0.0-a/VERSION	2010-10-21 20:59:32.000000000 +0000
  4.1608 ++++ mpfr-3.0.0-b/VERSION	2010-10-21 21:18:26.000000000 +0000
  4.1609 +@@ -1 +1 @@
  4.1610 +-3.0.0-p6
  4.1611 ++3.0.0-p7
  4.1612 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  4.1613 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 20:59:32.000000000 +0000
  4.1614 ++++ mpfr-3.0.0-b/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  4.1615 +@@ -27,7 +27,7 @@
  4.1616 + #define MPFR_VERSION_MAJOR 3
  4.1617 + #define MPFR_VERSION_MINOR 0
  4.1618 + #define MPFR_VERSION_PATCHLEVEL 0
  4.1619 +-#define MPFR_VERSION_STRING "3.0.0-p6"
  4.1620 ++#define MPFR_VERSION_STRING "3.0.0-p7"
  4.1621 + 
  4.1622 + /* Macros dealing with MPFR VERSION */
  4.1623 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  4.1624 +diff -Naurd mpfr-3.0.0-a/set_ld.c mpfr-3.0.0-b/set_ld.c
  4.1625 +--- mpfr-3.0.0-a/set_ld.c	2010-06-10 11:00:14.000000000 +0000
  4.1626 ++++ mpfr-3.0.0-b/set_ld.c	2010-10-21 21:18:26.000000000 +0000
  4.1627 +@@ -102,21 +102,25 @@
  4.1628 +             {
  4.1629 +               x /= div13; /* exact */
  4.1630 +               shift_exp += 8192;
  4.1631 ++              mpfr_div_2si (t, t, 8192, MPFR_RNDZ);
  4.1632 +             }
  4.1633 +           if (ABS (x) >= div12)
  4.1634 +             {
  4.1635 +               x /= div12; /* exact */
  4.1636 +               shift_exp += 4096;
  4.1637 ++              mpfr_div_2si (t, t, 4096, MPFR_RNDZ);
  4.1638 +             }
  4.1639 +           if (ABS (x) >= div11)
  4.1640 +             {
  4.1641 +               x /= div11; /* exact */
  4.1642 +               shift_exp += 2048;
  4.1643 ++              mpfr_div_2si (t, t, 2048, MPFR_RNDZ);
  4.1644 +             }
  4.1645 +           if (ABS (x) >= div10)
  4.1646 +             {
  4.1647 +               x /= div10; /* exact */
  4.1648 +               shift_exp += 1024;
  4.1649 ++              mpfr_div_2si (t, t, 1024, MPFR_RNDZ);
  4.1650 +             }
  4.1651 +           /* warning: we may have DBL_MAX=2^1024*(1-2^(-53)) < x < 2^1024,
  4.1652 +              therefore we have one extra exponent reduction step */
  4.1653 +@@ -124,9 +128,10 @@
  4.1654 +             {
  4.1655 +               x /= div9; /* exact */
  4.1656 +               shift_exp += 512;
  4.1657 ++              mpfr_div_2si (t, t, 512, MPFR_RNDZ);
  4.1658 +             }
  4.1659 +         } /* Check overflow of double */
  4.1660 +-      else
  4.1661 ++      else /* no overflow on double */
  4.1662 +         {
  4.1663 +           long double div9, div10, div11;
  4.1664 + 
  4.1665 +@@ -149,29 +154,34 @@
  4.1666 +                 {
  4.1667 +                   x /= div13; /* exact */
  4.1668 +                   shift_exp -= 8192;
  4.1669 ++                  mpfr_mul_2si (t, t, 8192, MPFR_RNDZ);
  4.1670 +                 }
  4.1671 +               if (ABS (x) <= div12)
  4.1672 +                 {
  4.1673 +                   x /= div12; /* exact */
  4.1674 +                   shift_exp -= 4096;
  4.1675 ++                  mpfr_mul_2si (t, t, 4096, MPFR_RNDZ);
  4.1676 +                 }
  4.1677 +               if (ABS (x) <= div11)
  4.1678 +                 {
  4.1679 +                   x /= div11; /* exact */
  4.1680 +                   shift_exp -= 2048;
  4.1681 ++                  mpfr_mul_2si (t, t, 2048, MPFR_RNDZ);
  4.1682 +                 }
  4.1683 +               if (ABS (x) <= div10)
  4.1684 +                 {
  4.1685 +                   x /= div10; /* exact */
  4.1686 +                   shift_exp -= 1024;
  4.1687 ++                  mpfr_mul_2si (t, t, 1024, MPFR_RNDZ);
  4.1688 +                 }
  4.1689 +               if (ABS(x) <= div9)
  4.1690 +                 {
  4.1691 +                   x /= div9;  /* exact */
  4.1692 +                   shift_exp -= 512;
  4.1693 ++                  mpfr_mul_2si (t, t, 512, MPFR_RNDZ);
  4.1694 +                 }
  4.1695 +             }
  4.1696 +-          else
  4.1697 ++          else /* no underflow */
  4.1698 +             {
  4.1699 +               inexact = mpfr_set_d (u, (double) x, MPFR_RNDZ);
  4.1700 +               MPFR_ASSERTD (inexact == 0);
  4.1701 +diff -Naurd mpfr-3.0.0-a/tests/tset_ld.c mpfr-3.0.0-b/tests/tset_ld.c
  4.1702 +--- mpfr-3.0.0-a/tests/tset_ld.c	2010-06-10 11:00:13.000000000 +0000
  4.1703 ++++ mpfr-3.0.0-b/tests/tset_ld.c	2010-10-21 21:18:26.000000000 +0000
  4.1704 +@@ -147,12 +147,39 @@
  4.1705 + test_fixed_bugs (void)
  4.1706 + {
  4.1707 +   mpfr_t x;
  4.1708 +-  long double d;
  4.1709 ++  long double l, m;
  4.1710 + 
  4.1711 +   /* bug found by Steve Kargl (2009-03-14) */
  4.1712 +   mpfr_init2 (x, 64);
  4.1713 +   mpfr_set_ui_2exp (x, 1, -16447, MPFR_RNDN);
  4.1714 +-  d = mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  4.1715 ++  mpfr_get_ld (x, MPFR_RNDN);  /* an assertion failed in init2.c:50 */
  4.1716 ++
  4.1717 ++  /* bug reported by Jakub Jelinek (2010-10-17)
  4.1718 ++     https://gforge.inria.fr/tracker/?func=detail&aid=11300 */
  4.1719 ++  mpfr_set_prec (x, MPFR_LDBL_MANT_DIG);
  4.1720 ++  /* l = 0x1.23456789abcdef0123456789abcdp-914L; */
  4.1721 ++  l = 8.215640181713713164092636634579e-276;
  4.1722 ++  mpfr_set_ld (x, l, MPFR_RNDN);
  4.1723 ++  m = mpfr_get_ld (x, MPFR_RNDN);
  4.1724 ++  if (m != l)
  4.1725 ++    {
  4.1726 ++      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  4.1727 ++      printf ("Got m=%Le instead of l\n", m);
  4.1728 ++      exit (1);
  4.1729 ++    }
  4.1730 ++
  4.1731 ++  /* another similar test which failed with extended double precision and the
  4.1732 ++     generic code for mpfr_set_ld */
  4.1733 ++  /* l = 0x1.23456789abcdef0123456789abcdp-968L; */
  4.1734 ++  l = 4.560596445887084662336528403703e-292;
  4.1735 ++  mpfr_set_ld (x, l, MPFR_RNDN);
  4.1736 ++  m = mpfr_get_ld (x, MPFR_RNDN);
  4.1737 ++  if (m != l)
  4.1738 ++    {
  4.1739 ++      printf ("Error in get_ld o set_ld for l=%Le\n", l);
  4.1740 ++      printf ("Got m=%Le instead of l\n", m);
  4.1741 ++      exit (1);
  4.1742 ++    }
  4.1743 + 
  4.1744 +   mpfr_clear (x);
  4.1745 + }
  4.1746 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  4.1747 +--- mpfr-3.0.0-a/version.c	2010-10-21 20:59:32.000000000 +0000
  4.1748 ++++ mpfr-3.0.0-b/version.c	2010-10-21 21:18:26.000000000 +0000
  4.1749 +@@ -25,5 +25,5 @@
  4.1750 + const char *
  4.1751 + mpfr_get_version (void)
  4.1752 + {
  4.1753 +-  return "3.0.0-p6";
  4.1754 ++  return "3.0.0-p7";
  4.1755 + }
  4.1756 +diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
  4.1757 +--- mpfr-3.0.0-a/PATCHES	2010-11-09 15:15:07.000000000 +0000
  4.1758 ++++ mpfr-3.0.0-b/PATCHES	2010-11-09 15:15:07.000000000 +0000
  4.1759 +@@ -0,0 +1 @@
  4.1760 ++macros
  4.1761 +diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
  4.1762 +--- mpfr-3.0.0-a/VERSION	2010-10-21 21:18:26.000000000 +0000
  4.1763 ++++ mpfr-3.0.0-b/VERSION	2010-11-09 15:15:07.000000000 +0000
  4.1764 +@@ -1 +1 @@
  4.1765 +-3.0.0-p7
  4.1766 ++3.0.0-p8
  4.1767 +diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
  4.1768 +--- mpfr-3.0.0-a/mpfr.h	2010-10-21 21:18:26.000000000 +0000
  4.1769 ++++ mpfr-3.0.0-b/mpfr.h	2010-11-09 15:15:07.000000000 +0000
  4.1770 +@@ -27,7 +27,7 @@
  4.1771 + #define MPFR_VERSION_MAJOR 3
  4.1772 + #define MPFR_VERSION_MINOR 0
  4.1773 + #define MPFR_VERSION_PATCHLEVEL 0
  4.1774 +-#define MPFR_VERSION_STRING "3.0.0-p7"
  4.1775 ++#define MPFR_VERSION_STRING "3.0.0-p8"
  4.1776 + 
  4.1777 + /* Macros dealing with MPFR VERSION */
  4.1778 + #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
  4.1779 +@@ -67,6 +67,16 @@
  4.1780 + # define _MPFR_H_HAVE_INTMAX_T 1
  4.1781 + #endif
  4.1782 + 
  4.1783 ++/* Avoid some problems with macro expansion if the user defines macros
  4.1784 ++   with the same name as keywords. By convention, identifiers and macro
  4.1785 ++   names starting with mpfr_ are reserved by MPFR. */
  4.1786 ++typedef void            mpfr_void;
  4.1787 ++typedef int             mpfr_int;
  4.1788 ++typedef unsigned int    mpfr_uint;
  4.1789 ++typedef long            mpfr_long;
  4.1790 ++typedef unsigned long   mpfr_ulong;
  4.1791 ++typedef size_t          mpfr_size_t;
  4.1792 ++
  4.1793 + /* Definition of rounding modes (DON'T USE MPFR_RNDNA!).
  4.1794 +    Warning! Changing the contents of this enum should be seen as an
  4.1795 +    interface change since the old and the new types are not compatible
  4.1796 +@@ -136,7 +146,7 @@
  4.1797 + typedef mp_exp_t     mpfr_exp_t;
  4.1798 + 
  4.1799 + /* Definition of the standard exponent limits */
  4.1800 +-#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((unsigned long) 1 << 30) - 1))
  4.1801 ++#define MPFR_EMAX_DEFAULT ((mpfr_exp_t) (((mpfr_ulong) 1 << 30) - 1))
  4.1802 + #define MPFR_EMIN_DEFAULT (-(MPFR_EMAX_DEFAULT))
  4.1803 + 
  4.1804 + /* Definition of the main structure */
  4.1805 +@@ -725,13 +735,13 @@
  4.1806 +    unexpected results with future compilers and aggressive optimisations.
  4.1807 +    Why not working only with signed types, using INT_MIN and LONG_MIN? */
  4.1808 + #if __GMP_MP_SIZE_T_INT
  4.1809 +-#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+2))
  4.1810 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+1))
  4.1811 +-#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned int)0)>>1))+3))
  4.1812 ++#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+2))
  4.1813 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+1))
  4.1814 ++#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_uint)0)>>1))+3))
  4.1815 + #else
  4.1816 +-#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+2))
  4.1817 +-#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+1))
  4.1818 +-#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(unsigned long)0)>>1))+3))
  4.1819 ++#define __MPFR_EXP_NAN  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+2))
  4.1820 ++#define __MPFR_EXP_ZERO ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+1))
  4.1821 ++#define __MPFR_EXP_INF  ((mpfr_exp_t)((~((~(mpfr_ulong)0)>>1))+3))
  4.1822 + #endif
  4.1823 + 
  4.1824 + /* Define MPFR_USE_EXTENSION to avoid "gcc -pedantic" warnings. */
  4.1825 +@@ -760,9 +770,9 @@
  4.1826 + #define mpfr_inf_p(_x)      ((_x)->_mpfr_exp == __MPFR_EXP_INF)
  4.1827 + #define mpfr_zero_p(_x)     ((_x)->_mpfr_exp == __MPFR_EXP_ZERO)
  4.1828 + #define mpfr_regular_p(_x)  ((_x)->_mpfr_exp >  __MPFR_EXP_INF)
  4.1829 +-#define mpfr_sgn(_x)                                          \
  4.1830 +-  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                         \
  4.1831 +-   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (void) 0), 0 : \
  4.1832 ++#define mpfr_sgn(_x)                                               \
  4.1833 ++  ((_x)->_mpfr_exp < __MPFR_EXP_INF ?                              \
  4.1834 ++   (mpfr_nan_p (_x) ? mpfr_set_erangeflag () : (mpfr_void) 0), 0 : \
  4.1835 +    MPFR_SIGN (_x))
  4.1836 + 
  4.1837 + /* Prevent them from using as lvalues */
  4.1838 +@@ -805,7 +815,19 @@
  4.1839 +    Moreover casts to unsigned long have been added to avoid warnings in
  4.1840 +    programs that use MPFR and are compiled with -Wconversion; such casts
  4.1841 +    are OK since if X is a constant expression, then (unsigned long) X is
  4.1842 +-   also a constant expression, so that the optimizations still work. */
  4.1843 ++   also a constant expression, so that the optimizations still work. The
  4.1844 ++   warnings are probably related to the following two bugs:
  4.1845 ++     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=4210
  4.1846 ++     http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38470 (possibly a variant)
  4.1847 ++   and the casts could be removed once these bugs are fixed.
  4.1848 ++   Casts shouldn't be used on the generic calls (to the ..._2exp functions),
  4.1849 ++   where implicit conversions are performed. Indeed, having at least one
  4.1850 ++   implicit conversion in the macro allows the compiler to emit diagnostics
  4.1851 ++   when normally expected, for instance in the following call:
  4.1852 ++     mpfr_set_ui (x, "foo", MPFR_RNDN);
  4.1853 ++   If this is not possible (for future macros), one of the tricks described
  4.1854 ++   on http://groups.google.com/group/comp.std.c/msg/e92abd24bf9eaf7b could
  4.1855 ++   be used. */
  4.1856 + #if defined (__GNUC__) && !defined(__ICC) && !defined(__cplusplus)
  4.1857 + #if (__GNUC__ >= 2)
  4.1858 + #undef mpfr_cmp_ui
  4.1859 +@@ -813,45 +835,45 @@
  4.1860 +    But warning! mpfr_sgn is specified as a macro in the API, thus the macro
  4.1861 +    mustn't be used if side effects are possible, like here. */
  4.1862 + #define mpfr_cmp_ui(_f,_u)                                      \
  4.1863 +-  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  4.1864 ++  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  4.1865 +    (mpfr_sgn) (_f) :                                            \
  4.1866 +-   mpfr_cmp_ui_2exp ((_f), (unsigned long) (_u), 0))
  4.1867 ++   mpfr_cmp_ui_2exp ((_f), (_u), 0))
  4.1868 + #undef mpfr_cmp_si
  4.1869 +-#define mpfr_cmp_si(_f,_s)                              \
  4.1870 +-  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?      \
  4.1871 +-   mpfr_cmp_ui ((_f), (unsigned long) (long) (_s)) :    \
  4.1872 +-   mpfr_cmp_si_2exp ((_f), (long) (_s), 0))
  4.1873 ++#define mpfr_cmp_si(_f,_s)                                      \
  4.1874 ++  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  4.1875 ++   mpfr_cmp_ui ((_f), (mpfr_ulong) (mpfr_long) (_s)) :          \
  4.1876 ++   mpfr_cmp_si_2exp ((_f), (_s), 0))
  4.1877 + #if __GNUC__ > 2 || __GNUC_MINOR__ >= 95
  4.1878 + #undef mpfr_set_ui
  4.1879 + #define mpfr_set_ui(_f,_u,_r)                                   \
  4.1880 +-  (__builtin_constant_p (_u) && (unsigned long) (_u) == 0 ?     \
  4.1881 ++  (__builtin_constant_p (_u) && (mpfr_ulong) (_u) == 0 ?        \
  4.1882 +    __extension__ ({                                             \
  4.1883 +        mpfr_ptr _p = (_f);                                      \
  4.1884 +        _p->_mpfr_sign = 1;                                      \
  4.1885 +        _p->_mpfr_exp = __MPFR_EXP_ZERO;                         \
  4.1886 +-       (void) (_r); 0; }) :                                     \
  4.1887 +-   mpfr_set_ui_2exp ((_f), (unsigned long) (_u), 0, (_r)))
  4.1888 ++       (mpfr_void) (_r); 0; }) :                                \
  4.1889 ++   mpfr_set_ui_2exp ((_f), (_u), 0, (_r)))
  4.1890 + #endif
  4.1891 + #undef mpfr_set_si
  4.1892 + #define mpfr_set_si(_f,_s,_r)                                   \
  4.1893 +-  (__builtin_constant_p (_s) && (long) (_s) >= 0 ?              \
  4.1894 +-   mpfr_set_ui ((_f), (unsigned long) (long) (_s), (_r)) :      \
  4.1895 +-   mpfr_set_si_2exp ((_f), (long) (_s), 0, (_r)))
  4.1896 ++  (__builtin_constant_p (_s) && (mpfr_long) (_s) >= 0 ?         \
  4.1897 ++   mpfr_set_ui ((_f), (mpfr_ulong) (mpfr_long) (_s), (_r)) :    \
  4.1898 ++   mpfr_set_si_2exp ((_f), (_s), 0, (_r)))
  4.1899 + #endif
  4.1900 + #endif
  4.1901 + 
  4.1902 + /* Macro version of mpfr_stack interface for fast access */
  4.1903 +-#define mpfr_custom_get_size(p) ((size_t)                            \
  4.1904 ++#define mpfr_custom_get_size(p) ((mpfr_size_t)                          \
  4.1905 +        (((p)+GMP_NUMB_BITS-1)/GMP_NUMB_BITS*sizeof (mp_limb_t)))
  4.1906 + #define mpfr_custom_init(m,p) do {} while (0)
  4.1907 +-#define mpfr_custom_get_significand(x) ((void*)((x)->_mpfr_d))
  4.1908 ++#define mpfr_custom_get_significand(x) ((mpfr_void*)((x)->_mpfr_d))
  4.1909 + #define mpfr_custom_get_exp(x) ((x)->_mpfr_exp)
  4.1910 + #define mpfr_custom_move(x,m) do { ((x)->_mpfr_d = (mp_limb_t*)(m)); } while (0)
  4.1911 + #define mpfr_custom_init_set(x,k,e,p,m) do {                   \
  4.1912 +   mpfr_ptr _x = (x);                                           \
  4.1913 +   mpfr_exp_t _e;                                               \
  4.1914 +   mpfr_kind_t _t;                                              \
  4.1915 +-  int _s, _k;                                                  \
  4.1916 ++  mpfr_int _s, _k;                                             \
  4.1917 +   _k = (k);                                                    \
  4.1918 +   if (_k >= 0)  {                                              \
  4.1919 +     _t = (mpfr_kind_t) _k;                                     \
  4.1920 +@@ -868,11 +890,13 @@
  4.1921 +   _x->_mpfr_exp  = _e;                                         \
  4.1922 +   _x->_mpfr_d    = (mp_limb_t*) (m);                           \
  4.1923 +  } while (0)
  4.1924 +-#define mpfr_custom_get_kind(x)                                              \
  4.1925 +-  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ? (int)MPFR_REGULAR_KIND*MPFR_SIGN (x) \
  4.1926 +-  : (x)->_mpfr_exp == __MPFR_EXP_INF ? (int)MPFR_INF_KIND*MPFR_SIGN (x)     \
  4.1927 +-  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (int)MPFR_NAN_KIND                   \
  4.1928 +-  : (int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  4.1929 ++#define mpfr_custom_get_kind(x)                                         \
  4.1930 ++  ( (x)->_mpfr_exp >  __MPFR_EXP_INF ?                                  \
  4.1931 ++    (mpfr_int) MPFR_REGULAR_KIND * MPFR_SIGN (x)                        \
  4.1932 ++  : (x)->_mpfr_exp == __MPFR_EXP_INF ?                                  \
  4.1933 ++    (mpfr_int) MPFR_INF_KIND * MPFR_SIGN (x)                            \
  4.1934 ++  : (x)->_mpfr_exp == __MPFR_EXP_NAN ? (mpfr_int) MPFR_NAN_KIND         \
  4.1935 ++  : (mpfr_int) MPFR_ZERO_KIND * MPFR_SIGN (x) )
  4.1936 + 
  4.1937 + 
  4.1938 + #endif /* MPFR_USE_NO_MACRO */
  4.1939 +diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
  4.1940 +--- mpfr-3.0.0-a/version.c	2010-10-21 21:18:26.000000000 +0000
  4.1941 ++++ mpfr-3.0.0-b/version.c	2010-11-09 15:15:07.000000000 +0000
  4.1942 +@@ -25,5 +25,5 @@
  4.1943 + const char *
  4.1944 + mpfr_get_version (void)
  4.1945 + {
  4.1946 +-  return "3.0.0-p7";
  4.1947 ++  return "3.0.0-p8";
  4.1948 + }