wok rev 19615

Up: mpfr (3.1.5)
author Alexander Medvedev <devl547@gmail.com>
date Mon Jan 09 19:50:23 2017 +0000 (2017-01-09)
parents e56f9ed5622e
children 79e0a7b1e329
files mpfr-dev/receipt mpfr/receipt mpfr/stuff/mpfr-3.1.0.patch mpfr/stuff/mpfr-3.1.2-upstream_fixes-3.patch
line diff
     1.1 --- a/mpfr-dev/receipt	Mon Jan 09 19:48:10 2017 +0000
     1.2 +++ b/mpfr-dev/receipt	Mon Jan 09 19:50:23 2017 +0000
     1.3 @@ -1,7 +1,7 @@
     1.4  # SliTaz package receipt
     1.5  
     1.6  PACKAGE="mpfr-dev"
     1.7 -VERSION="3.1.4"
     1.8 +VERSION="3.1.5"
     1.9  CATEGORY="development"
    1.10  SHORT_DESC="GNU Multiple Precision Arithmetic devel files."
    1.11  MAINTAINER="pankso@slitaz.org"
     2.1 --- a/mpfr/receipt	Mon Jan 09 19:48:10 2017 +0000
     2.2 +++ b/mpfr/receipt	Mon Jan 09 19:50:23 2017 +0000
     2.3 @@ -1,7 +1,7 @@
     2.4  # SliTaz package receipt
     2.5  
     2.6  PACKAGE="mpfr"
     2.7 -VERSION="3.1.4"
     2.8 +VERSION="3.1.5"
     2.9  CATEGORY="development"
    2.10  SHORT_DESC="C library for multiple-precision floating-point computations."
    2.11  MAINTAINER="pankso@slitaz.org"
    2.12 @@ -20,7 +20,6 @@
    2.13  # Rules to configure and make the package.
    2.14  compile_rules()
    2.15  {
    2.16 -	patch -Np1 -i $stuff/mpfr-3.1.2-upstream_fixes-3.patch
    2.17  	case "$ARCH" in
    2.18  	i?86)
    2.19  		./configure \
     3.1 --- a/mpfr/stuff/mpfr-3.1.0.patch	Mon Jan 09 19:48:10 2017 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,473 +0,0 @@
     3.4 -Submitted By:            Matt Burgess <matthew_at_linuxfromscratch_dot_org>
     3.5 -Date:                    2011-12-22
     3.6 -Initial Package Version: 3.1.0
     3.7 -Upstream Status:         Already in upstream patch repo
     3.8 -Origin:                  Upstream
     3.9 -Description:             This patch contains patches for several bugs in MPFR,
    3.10 -                         the main one being a rounding related error with the
    3.11 -                         mpfr_*printf functions.
    3.12 -
    3.13 -diff -Naur mpfr-3.1.0.orig/PATCHES mpfr-3.1.0/PATCHES
    3.14 ---- mpfr-3.1.0.orig/PATCHES	2011-10-03 08:17:15.000000000 +0000
    3.15 -+++ mpfr-3.1.0/PATCHES	2011-12-22 11:08:42.188819413 +0000
    3.16 -@@ -0,0 +1,4 @@
    3.17 -+gmp41compat
    3.18 -+vasprintf
    3.19 -+lib-search-path
    3.20 -+mpfr_unlikely
    3.21 -diff -Naur mpfr-3.1.0.orig/VERSION mpfr-3.1.0/VERSION
    3.22 ---- mpfr-3.1.0.orig/VERSION	2011-10-03 08:17:15.000000000 +0000
    3.23 -+++ mpfr-3.1.0/VERSION	2011-11-28 12:22:52.000000000 +0000
    3.24 -@@ -1 +1 @@
    3.25 --3.1.0
    3.26 -+3.1.0-p4
    3.27 -diff -Naur mpfr-3.1.0.orig/doc/mpfr.info mpfr-3.1.0/doc/mpfr.info
    3.28 ---- mpfr-3.1.0.orig/doc/mpfr.info	2011-10-03 09:43:04.000000000 +0000
    3.29 -+++ mpfr-3.1.0/doc/mpfr.info	2011-11-28 12:22:52.000000000 +0000
    3.30 -@@ -2994,11 +2994,12 @@
    3.31 - 
    3.32 -    * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1.  Their
    3.33 -      behavior no longer depends on the platform (assuming this is also
    3.34 --     true for GMP's random generator).  As a consequence, the returned
    3.35 --     values can be different between MPFR 3.1 and previous MPFR
    3.36 --     versions.  Note: as the reproducibility of these functions was not
    3.37 --     specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ regarded
    3.38 --     as backward incompatible with previous versions.
    3.39 -+     true for GMP's random generator, which is not the case between GMP
    3.40 -+     4.1 and 4.2 if `gmp_randinit_default' is used).  As a consequence,
    3.41 -+     the returned values can be different between MPFR 3.1 and previous
    3.42 -+     MPFR versions.  Note: as the reproducibility of these functions
    3.43 -+     was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_
    3.44 -+     regarded as backward incompatible with previous versions.
    3.45 - 
    3.46 - 
    3.47 - 
    3.48 -@@ -4239,13 +4240,13 @@
    3.49 - Node: Type and Macro Changes129308
    3.50 - Node: Added Functions132029
    3.51 - Node: Changed Functions134972
    3.52 --Node: Removed Functions139167
    3.53 --Node: Other Changes139579
    3.54 --Node: Contributors141108
    3.55 --Node: References143574
    3.56 --Node: GNU Free Documentation License145315
    3.57 --Node: Concept Index167758
    3.58 --Node: Function and Type Index173677
    3.59 -+Node: Removed Functions139253
    3.60 -+Node: Other Changes139665
    3.61 -+Node: Contributors141194
    3.62 -+Node: References143660
    3.63 -+Node: GNU Free Documentation License145401
    3.64 -+Node: Concept Index167844
    3.65 -+Node: Function and Type Index173763
    3.66 - 
    3.67 - End Tag Table
    3.68 - 
    3.69 -diff -Naur mpfr-3.1.0.orig/doc/mpfr.texi mpfr-3.1.0/doc/mpfr.texi
    3.70 ---- mpfr-3.1.0.orig/doc/mpfr.texi	2011-10-03 08:17:14.000000000 +0000
    3.71 -+++ mpfr-3.1.0/doc/mpfr.texi	2011-11-28 12:22:52.000000000 +0000
    3.72 -@@ -3466,8 +3466,9 @@
    3.73 - a lack of specification.
    3.74 - 
    3.75 - @item @code{mpfr_urandom} and @code{mpfr_urandomb} changed in MPFR 3.1.
    3.76 --Their behavior no longer depends on the platform (assuming this is also
    3.77 --true for GMP's random generator).  As a consequence, the returned values
    3.78 -+Their behavior no longer depends on the platform (assuming this is also true
    3.79 -+for GMP's random generator, which is not the case between GMP 4.1 and 4.2 if
    3.80 -+@code{gmp_randinit_default} is used).  As a consequence, the returned values
    3.81 - can be different between MPFR 3.1 and previous MPFR versions.
    3.82 - Note: as the reproducibility of these functions was not specified
    3.83 - before MPFR 3.1, the MPFR 3.1 behavior is @emph{not} regarded as
    3.84 -diff -Naur mpfr-3.1.0.orig/src/mpfr-impl.h mpfr-3.1.0/src/mpfr-impl.h
    3.85 ---- mpfr-3.1.0.orig/src/mpfr-impl.h	2011-10-03 08:17:09.000000000 +0000
    3.86 -+++ mpfr-3.1.0/src/mpfr-impl.h	2011-10-05 21:39:57.000000000 +0000
    3.87 -@@ -988,10 +988,11 @@
    3.88 -  ******************************************************/
    3.89 - 
    3.90 - /* Theses macros help the compiler to determine if a test is
    3.91 -- * likely or unlikely. */
    3.92 -+   likely or unlikely. The !! is necessary in case x is larger
    3.93 -+   than a long. */
    3.94 - #if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
    3.95 - # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
    3.96 --# define MPFR_UNLIKELY(x) (__builtin_expect((x),0))
    3.97 -+# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0))
    3.98 - #else
    3.99 - # define MPFR_LIKELY(x) (x)
   3.100 - # define MPFR_UNLIKELY(x) (x)
   3.101 -diff -Naur mpfr-3.1.0.orig/src/mpfr.h mpfr-3.1.0/src/mpfr.h
   3.102 ---- mpfr-3.1.0.orig/src/mpfr.h	2011-10-03 08:17:09.000000000 +0000
   3.103 -+++ mpfr-3.1.0/src/mpfr.h	2011-11-28 12:22:52.000000000 +0000
   3.104 -@@ -27,7 +27,7 @@
   3.105 - #define MPFR_VERSION_MAJOR 3
   3.106 - #define MPFR_VERSION_MINOR 1
   3.107 - #define MPFR_VERSION_PATCHLEVEL 0
   3.108 --#define MPFR_VERSION_STRING "3.1.0"
   3.109 -+#define MPFR_VERSION_STRING "3.1.0-p4"
   3.110 - 
   3.111 - /* Macros dealing with MPFR VERSION */
   3.112 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   3.113 -diff -Naur mpfr-3.1.0.orig/src/vasprintf.c mpfr-3.1.0/src/vasprintf.c
   3.114 ---- mpfr-3.1.0.orig/src/vasprintf.c	2011-10-03 08:17:09.000000000 +0000
   3.115 -+++ mpfr-3.1.0/src/vasprintf.c	2011-11-03 15:15:11.000000000 +0000
   3.116 -@@ -1178,7 +1178,7 @@
   3.117 -   mpfr_exp_t exp;
   3.118 -   char * str;
   3.119 -   const int spec_g = (spec.spec == 'g' || spec.spec == 'G');
   3.120 --  const int keep_trailing_zeros = spec_g && spec.alt;
   3.121 -+  const int keep_trailing_zeros = !spec_g || spec.alt;
   3.122 - 
   3.123 -   /* WARNING: an empty precision field is forbidden (it means precision = 6
   3.124 -      and it should have been changed to 6 before the function call) */
   3.125 -@@ -1356,7 +1356,7 @@
   3.126 -   else
   3.127 -     /* 1 <= |p| */
   3.128 -     {
   3.129 --      size_t nsd;  /* Number of significant digits */
   3.130 -+      size_t str_len;
   3.131 - 
   3.132 -       /* Determine the position of the most significant decimal digit. */
   3.133 -       exp = floor_log10 (p);
   3.134 -@@ -1365,12 +1365,10 @@
   3.135 -         /* P is too large to print all its integral part digits */
   3.136 -         return -1;
   3.137 - 
   3.138 --      np->ip_size = exp + 1;
   3.139 --
   3.140 --      nsd = spec.prec + np->ip_size;
   3.141 -       if (dec_info == NULL)
   3.142 --        {
   3.143 --          str = mpfr_get_str (NULL, &exp, 10, nsd, p, spec.rnd_mode);
   3.144 -+        { /* this case occurs with mpfr_printf ("%.0RUf", x) with x=9.5 */
   3.145 -+          str =
   3.146 -+            mpfr_get_str (NULL, &exp, 10, spec.prec+exp+1, p, spec.rnd_mode);
   3.147 -           register_string (np->sl, str);
   3.148 -         }
   3.149 -       else
   3.150 -@@ -1379,81 +1377,60 @@
   3.151 -           str = dec_info->str;
   3.152 -         }
   3.153 -       np->ip_ptr = MPFR_IS_NEG (p) ? ++str : str; /* skip sign */
   3.154 -+      str_len = strlen (str);
   3.155 -+
   3.156 -+      /* integral part */
   3.157 -+      if (exp > str_len)
   3.158 -+        /* mpfr_get_str gives no trailing zero when p is rounded up to the next
   3.159 -+           power of 10 (p integer, so no fractional part) */
   3.160 -+        {
   3.161 -+          np->ip_trailing_zeros = exp - str_len;
   3.162 -+          np->ip_size = str_len;
   3.163 -+        }
   3.164 -+      else
   3.165 -+        np->ip_size = exp;
   3.166 - 
   3.167 -       if (spec.group)
   3.168 -         /* thousands separator in integral part */
   3.169 -         np->thousands_sep = MPFR_THOUSANDS_SEPARATOR;
   3.170 - 
   3.171 --      if (nsd == 0 || (spec_g && !spec.alt))
   3.172 --        /* compute how much non-zero digits in integral and fractional
   3.173 --           parts */
   3.174 -+      /* fractional part */
   3.175 -+      str += np->ip_size;
   3.176 -+      str_len -= np->ip_size;
   3.177 -+      if (!keep_trailing_zeros)
   3.178 -+        /* remove trailing zeros, if any */
   3.179 -         {
   3.180 --          size_t str_len;
   3.181 --          str_len = strlen (str); /* note: the sign has been skipped */
   3.182 --
   3.183 --          if (exp > str_len)
   3.184 --            /* mpfr_get_str doesn't give the trailing zeros when p is a
   3.185 --               multiple of 10 (p integer, so no fractional part) */
   3.186 -+          char *ptr = str + str_len - 1; /* pointer to the last digit of
   3.187 -+                                            str */
   3.188 -+          while ((*ptr == '0') && (str_len != 0))
   3.189 -             {
   3.190 --              np->ip_trailing_zeros = exp - str_len;
   3.191 --              np->ip_size = str_len;
   3.192 --              if (spec.alt)
   3.193 --                np->point = MPFR_DECIMAL_POINT;
   3.194 --            }
   3.195 --          else
   3.196 --            /* str may contain some digits which are in fractional part */
   3.197 --            {
   3.198 --              char *ptr;
   3.199 --
   3.200 --              ptr = str + str_len - 1; /* points to the end of str */
   3.201 --              str_len -= np->ip_size;  /* number of digits in fractional
   3.202 --                                          part */
   3.203 --
   3.204 --              if (!keep_trailing_zeros)
   3.205 --                /* remove trailing zeros, if any */
   3.206 --                {
   3.207 --                  while ((*ptr == '0') && (str_len != 0))
   3.208 --                    {
   3.209 --                      --ptr;
   3.210 --                      --str_len;
   3.211 --                    }
   3.212 --                }
   3.213 --
   3.214 --              if (str_len > INT_MAX)
   3.215 --                /* too many digits in fractional part */
   3.216 --                return -1;
   3.217 --
   3.218 --              if (str_len != 0)
   3.219 --                /* some digits in fractional part */
   3.220 --                {
   3.221 --                  np->point = MPFR_DECIMAL_POINT;
   3.222 --                  np->fp_ptr = str + np->ip_size;
   3.223 --                  np->fp_size = str_len;
   3.224 --                }
   3.225 -+              --ptr;
   3.226 -+              --str_len;
   3.227 -             }
   3.228 -         }
   3.229 --      else
   3.230 --        /* spec.prec digits in fractional part */
   3.231 --        {
   3.232 --          if (np->ip_size == exp - 1)
   3.233 --            /* the absolute value of the number has been rounded up to a power
   3.234 --               of ten.
   3.235 --               Insert an additional zero in integral part and put the rest of
   3.236 --               them in fractional part. */
   3.237 --            np->ip_trailing_zeros = 1;
   3.238 - 
   3.239 --          if (spec.prec != 0)
   3.240 --            {
   3.241 --              MPFR_ASSERTD (np->ip_size + np->ip_trailing_zeros == exp);
   3.242 --              MPFR_ASSERTD (np->ip_size + spec.prec == nsd);
   3.243 -+      if (str_len > 0)
   3.244 -+        /* some nonzero digits in fractional part */
   3.245 -+        {
   3.246 -+          if (str_len > INT_MAX)
   3.247 -+            /* too many digits in fractional part */
   3.248 -+            return -1;
   3.249 -+
   3.250 -+          np->point = MPFR_DECIMAL_POINT;
   3.251 -+          np->fp_ptr = str;
   3.252 -+          np->fp_size = str_len;
   3.253 -+        }
   3.254 - 
   3.255 --              np->point = MPFR_DECIMAL_POINT;
   3.256 --              np->fp_ptr = str + np->ip_size;
   3.257 --              np->fp_size = spec.prec;
   3.258 --            }
   3.259 --          else if (spec.alt)
   3.260 --            np->point = MPFR_DECIMAL_POINT;
   3.261 -+      if (keep_trailing_zeros && str_len < spec.prec)
   3.262 -+        /* add missing trailing zeros */
   3.263 -+        {
   3.264 -+          np->point = MPFR_DECIMAL_POINT;
   3.265 -+          np->fp_trailing_zeros = spec.prec - np->fp_size;
   3.266 -         }
   3.267 -+
   3.268 -+      if (spec.alt)
   3.269 -+        /* add decimal point even if no digits follow it */
   3.270 -+        np->point = MPFR_DECIMAL_POINT;
   3.271 -     }
   3.272 - 
   3.273 -   return 0;
   3.274 -diff -Naur mpfr-3.1.0.orig/src/version.c mpfr-3.1.0/src/version.c
   3.275 ---- mpfr-3.1.0.orig/src/version.c	2011-10-03 08:17:09.000000000 +0000
   3.276 -+++ mpfr-3.1.0/src/version.c	2011-11-28 12:22:52.000000000 +0000
   3.277 -@@ -25,5 +25,5 @@
   3.278 - const char *
   3.279 - mpfr_get_version (void)
   3.280 - {
   3.281 --  return "3.1.0";
   3.282 -+  return "3.1.0-p4";
   3.283 - }
   3.284 -diff -Naur mpfr-3.1.0.orig/tests/Makefile.am mpfr-3.1.0/tests/Makefile.am
   3.285 ---- mpfr-3.1.0.orig/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   3.286 -+++ mpfr-3.1.0/tests/Makefile.am	2011-10-03 08:17:14.000000000 +0000
   3.287 -@@ -65,8 +65,24 @@
   3.288 - TESTS = $(check_PROGRAMS)
   3.289 - TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   3.290 - 
   3.291 --# Option to prevent libtool from generating wrapper scripts for the tests.
   3.292 -+# The -no-install option prevents libtool from generating wrapper scripts
   3.293 -+# for the tests.
   3.294 - # This is useful to easily run the test scripts under valgrind or gdb.
   3.295 - # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   3.296 - # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   3.297 --AM_LDFLAGS = -no-install
   3.298 -+#
   3.299 -+# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   3.300 -+# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   3.301 -+# library is already installed in the corresponding lib directory: its
   3.302 -+# purpose is to make sure that the local .libs comes first in the library
   3.303 -+# search path (otherwise the tests are linked against the old MPFR library
   3.304 -+# by the LINK command -- see the generated Makefile). See:
   3.305 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   3.306 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   3.307 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   3.308 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   3.309 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   3.310 -+# and
   3.311 -+#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   3.312 -+#
   3.313 -+AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   3.314 -diff -Naur mpfr-3.1.0.orig/tests/Makefile.in mpfr-3.1.0/tests/Makefile.in
   3.315 ---- mpfr-3.1.0.orig/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   3.316 -+++ mpfr-3.1.0/tests/Makefile.in	2011-10-03 08:17:35.000000000 +0000
   3.317 -@@ -1124,11 +1124,27 @@
   3.318 - TESTS = $(check_PROGRAMS)
   3.319 - TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
   3.320 - 
   3.321 --# Option to prevent libtool from generating wrapper scripts for the tests.
   3.322 -+# The -no-install option prevents libtool from generating wrapper scripts
   3.323 -+# for the tests.
   3.324 - # This is useful to easily run the test scripts under valgrind or gdb.
   3.325 - # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
   3.326 - # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
   3.327 --AM_LDFLAGS = -no-install
   3.328 -+#
   3.329 -+# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
   3.330 -+# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
   3.331 -+# library is already installed in the corresponding lib directory: its
   3.332 -+# purpose is to make sure that the local .libs comes first in the library
   3.333 -+# search path (otherwise the tests are linked against the old MPFR library
   3.334 -+# by the LINK command -- see the generated Makefile). See:
   3.335 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
   3.336 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
   3.337 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
   3.338 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
   3.339 -+#   http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
   3.340 -+# and
   3.341 -+#   http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
   3.342 -+#
   3.343 -+AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
   3.344 - all: all-am
   3.345 - 
   3.346 - .SUFFIXES:
   3.347 -diff -Naur mpfr-3.1.0.orig/tests/trandom.c mpfr-3.1.0/tests/trandom.c
   3.348 ---- mpfr-3.1.0.orig/tests/trandom.c	2011-10-03 08:17:14.000000000 +0000
   3.349 -+++ mpfr-3.1.0/tests/trandom.c	2011-11-28 12:22:52.000000000 +0000
   3.350 -@@ -114,21 +114,29 @@
   3.351 -   mpfr_t x;
   3.352 -   gmp_randstate_t s;
   3.353 - 
   3.354 -+#if __MPFR_GMP(4,2,0)
   3.355 -+# define C1 "0.895943"
   3.356 -+# define C2 "0.848824"
   3.357 -+#else
   3.358 -+# define C1 "0.479652"
   3.359 -+# define C2 "0.648529"
   3.360 -+#endif
   3.361 -+
   3.362 -   gmp_randinit_default (s);
   3.363 -   gmp_randseed_ui (s, 42);
   3.364 -   mpfr_init2 (x, 17);
   3.365 -   mpfr_urandomb (x, s);
   3.366 --  if (mpfr_cmp_str1 (x, "0.895943") != 0)
   3.367 -+  if (mpfr_cmp_str1 (x, C1) != 0)
   3.368 -     {
   3.369 --      printf ("Error in bug20100914, expected 0.895943, got ");
   3.370 -+      printf ("Error in bug20100914, expected " C1 ", got ");
   3.371 -       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.372 -       printf ("\n");
   3.373 -       exit (1);
   3.374 -     }
   3.375 -   mpfr_urandomb (x, s);
   3.376 --  if (mpfr_cmp_str1 (x, "0.848824") != 0)
   3.377 -+  if (mpfr_cmp_str1 (x, C2) != 0)
   3.378 -     {
   3.379 --      printf ("Error in bug20100914, expected 0.848824, got ");
   3.380 -+      printf ("Error in bug20100914, expected " C2 ", got ");
   3.381 -       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.382 -       printf ("\n");
   3.383 -       exit (1);
   3.384 -diff -Naur mpfr-3.1.0.orig/tests/tsprintf.c mpfr-3.1.0/tests/tsprintf.c
   3.385 ---- mpfr-3.1.0.orig/tests/tsprintf.c	2011-10-03 08:17:14.000000000 +0000
   3.386 -+++ mpfr-3.1.0/tests/tsprintf.c	2011-11-03 15:15:11.000000000 +0000
   3.387 -@@ -475,6 +475,18 @@
   3.388 -   check_sprintf ("-1.", "%- #0.1RG", x);
   3.389 - 
   3.390 -   /* precision zero */
   3.391 -+  mpfr_set_d (x, 9.5, MPFR_RNDN);
   3.392 -+  check_sprintf ("9",    "%.0RDf", x);
   3.393 -+  check_sprintf ("10",    "%.0RUf", x);
   3.394 -+
   3.395 -+  mpfr_set_d (x, 19.5, MPFR_RNDN);
   3.396 -+  check_sprintf ("19",    "%.0RDf", x);
   3.397 -+  check_sprintf ("20",    "%.0RUf", x);
   3.398 -+
   3.399 -+  mpfr_set_d (x, 99.5, MPFR_RNDN);
   3.400 -+  check_sprintf ("99",    "%.0RDf", x);
   3.401 -+  check_sprintf ("100",   "%.0RUf", x);
   3.402 -+
   3.403 -   mpfr_set_d (x, -9.5, MPFR_RNDN);
   3.404 -   check_sprintf ("-10",    "%.0RDf", x);
   3.405 -   check_sprintf ("-10",    "%.0RYf", x);
   3.406 -@@ -1078,6 +1090,23 @@
   3.407 -   mpfr_clear (x);
   3.408 - }
   3.409 - 
   3.410 -+static void
   3.411 -+bug20111102 (void)
   3.412 -+{
   3.413 -+  mpfr_t t;
   3.414 -+  char s[100];
   3.415 -+
   3.416 -+  mpfr_init2 (t, 84);
   3.417 -+  mpfr_set_str (t, "999.99999999999999999999", 10, MPFR_RNDN);
   3.418 -+  mpfr_sprintf (s, "%.20RNg", t);
   3.419 -+  if (strcmp (s, "1000") != 0)
   3.420 -+    {
   3.421 -+      printf ("Error in bug20111102, expected 1000, got %s\n", s);
   3.422 -+      exit (1);
   3.423 -+    }
   3.424 -+  mpfr_clear (t);
   3.425 -+}
   3.426 -+
   3.427 - /* In particular, the following test makes sure that the rounding
   3.428 -  * for %Ra and %Rb is not done on the MPFR number itself (as it
   3.429 -  * would overflow). Note: it has been reported on comp.std.c that
   3.430 -@@ -1161,6 +1190,7 @@
   3.431 -   locale = setlocale (LC_ALL, "C");
   3.432 - #endif
   3.433 - 
   3.434 -+  bug20111102 ();
   3.435 -   native_types ();
   3.436 -   hexadecimal ();
   3.437 -   binary ();
   3.438 -diff -Naur mpfr-3.1.0.orig/tests/turandom.c mpfr-3.1.0/tests/turandom.c
   3.439 ---- mpfr-3.1.0.orig/tests/turandom.c	2011-10-03 08:17:14.000000000 +0000
   3.440 -+++ mpfr-3.1.0/tests/turandom.c	2011-11-28 12:22:52.000000000 +0000
   3.441 -@@ -160,23 +160,29 @@
   3.442 -   mpfr_t x;
   3.443 -   gmp_randstate_t s;
   3.444 - 
   3.445 -+#if __MPFR_GMP(4,2,0)
   3.446 -+# define C1 "0.8488312"
   3.447 -+# define C2 "0.8156509"
   3.448 -+#else
   3.449 -+# define C1 "0.6485367"
   3.450 -+# define C2 "0.9362717"
   3.451 -+#endif
   3.452 -+
   3.453 -   gmp_randinit_default (s);
   3.454 -   gmp_randseed_ui (s, 42);
   3.455 -   mpfr_init2 (x, 17);
   3.456 -   mpfr_urandom (x, s, MPFR_RNDN);
   3.457 --  /* the following values are obtained on a 32-bit computer, we should get
   3.458 --     the same values on a 64-bit computer */
   3.459 --  if (mpfr_cmp_str1 (x, "0.8488312") != 0)
   3.460 -+  if (mpfr_cmp_str1 (x, C1) != 0)
   3.461 -     {
   3.462 --      printf ("Error in bug20100914, expected 0.8488312, got ");
   3.463 -+      printf ("Error in bug20100914, expected " C1 ", got ");
   3.464 -       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.465 -       printf ("\n");
   3.466 -       exit (1);
   3.467 -     }
   3.468 -   mpfr_urandom (x, s, MPFR_RNDN);
   3.469 --  if (mpfr_cmp_str1 (x, "0.8156509") != 0)
   3.470 -+  if (mpfr_cmp_str1 (x, C2) != 0)
   3.471 -     {
   3.472 --      printf ("Error in bug20100914, expected 0.8156509, got ");
   3.473 -+      printf ("Error in bug20100914, expected " C2 ", got ");
   3.474 -       mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
   3.475 -       printf ("\n");
   3.476 -       exit (1);
     4.1 --- a/mpfr/stuff/mpfr-3.1.2-upstream_fixes-3.patch	Mon Jan 09 19:48:10 2017 +0000
     4.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.3 @@ -1,1199 +0,0 @@
     4.4 -Submitted By:            Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org>
     4.5 -Updated By:              Armin K. <krejzi at email dot com>
     4.6 -Date:                    2015-02-06
     4.7 -Initial Package Version: 3.1.2
     4.8 -Upstream Status:         Already in upstream patch repo
     4.9 -Origin:                  Upstream
    4.10 -Description:             This patch contains patches for several bugs in MPFR.
    4.11 -                         Note that the patch for configure.ac has been 
    4.12 -                         removed to prevent unneeded regeneration of build
    4.13 -                         files.
    4.14 -                         See http://www.mpfr.org/mpfr-current/allpatches
    4.15 -
    4.16 ---- a/PATCHES	2013-03-13 16:37:38.000000000 +0100
    4.17 -+++ b/PATCHES	2014-12-31 14:56:02.685641958 +0100
    4.18 -@@ -0,0 +1,11 @@
    4.19 -+strtofr
    4.20 -+vasprintf
    4.21 -+div-overflow
    4.22 -+gmp6-compat
    4.23 -+exp3
    4.24 -+li2-return
    4.25 -+custom_init_set
    4.26 -+printf-alt0
    4.27 -+clang-divby0
    4.28 -+fits-smallneg
    4.29 -+exp_2
    4.30 ---- a/src/div.c	2013-03-13 16:37:33.000000000 +0100
    4.31 -+++ b/src/div.c	2014-12-31 14:56:02.686641971 +0100
    4.32 -@@ -750,7 +750,9 @@
    4.33 -  truncate_check_qh:
    4.34 -   if (qh)
    4.35 -     {
    4.36 --      qexp ++;
    4.37 -+      if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
    4.38 -+        qexp ++;
    4.39 -+      /* else qexp is now incorrect, but one will still get an overflow */
    4.40 -       q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
    4.41 -     }
    4.42 -   goto truncate;
    4.43 -@@ -765,7 +767,9 @@
    4.44 -   inex = 1; /* always here */
    4.45 -   if (mpn_add_1 (q0p, q0p, q0size, MPFR_LIMB_ONE << sh))
    4.46 -     {
    4.47 --      qexp ++;
    4.48 -+      if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
    4.49 -+        qexp ++;
    4.50 -+      /* else qexp is now incorrect, but one will still get an overflow */
    4.51 -       q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
    4.52 -     }
    4.53 - 
    4.54 ---- a/src/exp_2.c	2013-03-13 16:37:28.000000000 +0100
    4.55 -+++ b/src/exp_2.c	2014-12-31 14:56:02.686641971 +0100
    4.56 -@@ -204,7 +204,7 @@
    4.57 -           for (k = 0; k < K; k++)
    4.58 -             {
    4.59 -               mpz_mul (ss, ss, ss);
    4.60 --              exps <<= 1;
    4.61 -+              exps *= 2;
    4.62 -               exps += mpz_normalize (ss, ss, q);
    4.63 -             }
    4.64 -           mpfr_set_z (s, ss, MPFR_RNDN);
    4.65 ---- a/src/exp3.c	2013-03-13 16:37:34.000000000 +0100
    4.66 -+++ b/src/exp3.c	2014-12-31 14:56:02.686641971 +0100
    4.67 -@@ -283,7 +283,7 @@
    4.68 -             }
    4.69 -         }
    4.70 - 
    4.71 --      if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDD, MPFR_RNDZ,
    4.72 -+      if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDN, MPFR_RNDZ,
    4.73 -                           MPFR_PREC(y) + (rnd_mode == MPFR_RNDN)))
    4.74 -         {
    4.75 -           inexact = mpfr_set (y, shift_x > 0 ? t : tmp, rnd_mode);
    4.76 ---- a/src/fits_u.h	2013-03-13 16:37:35.000000000 +0100
    4.77 -+++ b/src/fits_u.h	2014-12-31 14:56:02.686641971 +0100
    4.78 -@@ -32,17 +32,20 @@
    4.79 -   int res;
    4.80 - 
    4.81 -   if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
    4.82 --    /* Zero always fit */
    4.83 --    return MPFR_IS_ZERO (f) ? 1 : 0;
    4.84 --  else if (MPFR_IS_NEG (f))
    4.85 --    /* Negative numbers don't fit */
    4.86 --    return 0;
    4.87 --  /* now it fits if
    4.88 --     (a) f <= MAXIMUM
    4.89 --     (b) round(f, prec(slong), rnd) <= MAXIMUM */
    4.90 -+    return MPFR_IS_ZERO (f) ? 1 : 0;  /* Zero always fits */
    4.91 - 
    4.92 -   e = MPFR_GET_EXP (f);
    4.93 - 
    4.94 -+  if (MPFR_IS_NEG (f))
    4.95 -+    return e >= 1 ? 0  /* f <= -1 does not fit */
    4.96 -+      : rnd != MPFR_RNDN ? MPFR_IS_LIKE_RNDU (rnd, -1)  /* directed mode */
    4.97 -+      : e < 0 ? 1  /* f > -1/2 fits in MPFR_RNDN */
    4.98 -+      : mpfr_powerof2_raw(f);  /* -1/2 fits, -1 < f < -1/2 don't */
    4.99 -+
   4.100 -+  /* Now it fits if
   4.101 -+     (a) f <= MAXIMUM
   4.102 -+     (b) round(f, prec(slong), rnd) <= MAXIMUM */
   4.103 -+
   4.104 -   /* first compute prec(MAXIMUM); fits in an int */
   4.105 -   for (s = MAXIMUM, prec = 0; s != 0; s /= 2, prec ++);
   4.106 - 
   4.107 ---- a/src/fits_uintmax.c	2013-03-13 16:37:33.000000000 +0100
   4.108 -+++ b/src/fits_uintmax.c	2014-12-31 14:56:02.686641971 +0100
   4.109 -@@ -27,51 +27,19 @@
   4.110 - #include "mpfr-intmax.h"
   4.111 - #include "mpfr-impl.h"
   4.112 - 
   4.113 --#ifdef _MPFR_H_HAVE_INTMAX_T
   4.114 --
   4.115 --/* We can't use fits_u.h <= mpfr_cmp_ui */
   4.116 --int
   4.117 --mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
   4.118 --{
   4.119 --  mpfr_exp_t e;
   4.120 --  int prec;
   4.121 --  uintmax_t s;
   4.122 --  mpfr_t x;
   4.123 --  int res;
   4.124 --
   4.125 --  if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
   4.126 --    /* Zero always fit */
   4.127 --    return MPFR_IS_ZERO (f) ? 1 : 0;
   4.128 --  else if (MPFR_IS_NEG (f))
   4.129 --    /* Negative numbers don't fit */
   4.130 --    return 0;
   4.131 --  /* now it fits if
   4.132 --     (a) f <= MAXIMUM
   4.133 --     (b) round(f, prec(slong), rnd) <= MAXIMUM */
   4.134 --
   4.135 --  e = MPFR_GET_EXP (f);
   4.136 -+/* Note: though mpfr-impl.h is included in fits_u.h, we also include it
   4.137 -+   above so that it gets included even when _MPFR_H_HAVE_INTMAX_T is not
   4.138 -+   defined; this is necessary to avoid an empty translation unit, which
   4.139 -+   is forbidden by ISO C. Without this, a failing test can be reproduced
   4.140 -+   by creating an invalid stdint.h somewhere in the default include path
   4.141 -+   and by compiling MPFR with "gcc -ansi -pedantic-errors". */
   4.142 - 
   4.143 --  /* first compute prec(MAXIMUM); fits in an int */
   4.144 --  for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
   4.145 --
   4.146 --  /* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
   4.147 --
   4.148 --  /* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
   4.149 --  if (e <= prec - 1)
   4.150 --    return 1;
   4.151 --
   4.152 --  /* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
   4.153 --  if (e >= prec + 1)
   4.154 --    return 0;
   4.155 -+#ifdef _MPFR_H_HAVE_INTMAX_T
   4.156 - 
   4.157 --  MPFR_ASSERTD (e == prec);
   4.158 -+#define FUNCTION   mpfr_fits_uintmax_p
   4.159 -+#define MAXIMUM    MPFR_UINTMAX_MAX
   4.160 -+#define TYPE       uintmax_t
   4.161 - 
   4.162 --  /* hard case: first round to prec bits, then check */
   4.163 --  mpfr_init2 (x, prec);
   4.164 --  mpfr_set (x, f, rnd);
   4.165 --  res = MPFR_GET_EXP (x) == e;
   4.166 --  mpfr_clear (x);
   4.167 --  return res;
   4.168 --}
   4.169 -+#include "fits_u.h"
   4.170 - 
   4.171 - #endif
   4.172 ---- a/src/init2.c	2013-03-13 16:37:32.000000000 +0100
   4.173 -+++ b/src/init2.c	2014-12-31 14:56:02.686641971 +0100
   4.174 -@@ -30,11 +30,11 @@
   4.175 - 
   4.176 -   /* Check if we can represent the number of limbs
   4.177 -    * associated to the maximum of mpfr_prec_t*/
   4.178 --  MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/BYTES_PER_MP_LIMB) );
   4.179 -+  MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/MPFR_BYTES_PER_MP_LIMB) );
   4.180 - 
   4.181 --  /* Check for correct GMP_NUMB_BITS and BYTES_PER_MP_LIMB */
   4.182 --  MPFR_ASSERTN( GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
   4.183 --                && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB );
   4.184 -+  /* Check for correct GMP_NUMB_BITS and MPFR_BYTES_PER_MP_LIMB */
   4.185 -+  MPFR_ASSERTN( GMP_NUMB_BITS == MPFR_BYTES_PER_MP_LIMB * CHAR_BIT
   4.186 -+                && sizeof(mp_limb_t) == MPFR_BYTES_PER_MP_LIMB );
   4.187 - 
   4.188 -   MPFR_ASSERTN (mp_bits_per_limb == GMP_NUMB_BITS);
   4.189 - 
   4.190 ---- a/src/li2.c	2013-03-13 16:37:32.000000000 +0100
   4.191 -+++ b/src/li2.c	2014-12-31 14:56:02.686641971 +0100
   4.192 -@@ -630,5 +630,5 @@
   4.193 -       return mpfr_check_range (y, inexact, rnd_mode);
   4.194 -     }
   4.195 - 
   4.196 --  MPFR_ASSERTN (0);             /* should never reach this point */
   4.197 -+  MPFR_RET_NEVER_GO_HERE ();
   4.198 - }
   4.199 ---- a/src/mpfr-gmp.h	2013-03-13 16:37:32.000000000 +0100
   4.200 -+++ b/src/mpfr-gmp.h	2014-12-31 14:56:02.687641984 +0100
   4.201 -@@ -72,7 +72,6 @@
   4.202 - #endif
   4.203 - 
   4.204 - /* Define some macros */
   4.205 --#define BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
   4.206 - 
   4.207 - #define MP_LIMB_T_MAX (~(mp_limb_t)0)
   4.208 - 
   4.209 -@@ -96,19 +95,19 @@
   4.210 - #define SHRT_HIGHBIT       SHRT_MIN
   4.211 - 
   4.212 - /* MP_LIMB macros */
   4.213 --#define MPN_ZERO(dst, n) memset((dst), 0, (n)*BYTES_PER_MP_LIMB)
   4.214 --#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
   4.215 --#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
   4.216 -+#define MPN_ZERO(dst, n) memset((dst), 0, (n)*MPFR_BYTES_PER_MP_LIMB)
   4.217 -+#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
   4.218 -+#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
   4.219 - #define MPN_COPY(dst,src,n) \
   4.220 -   do                                                                  \
   4.221 -     {                                                                 \
   4.222 -       if ((dst) != (src))                                             \
   4.223 -         {                                                             \
   4.224 -           MPFR_ASSERTD ((char *) (dst) >= (char *) (src) +            \
   4.225 --                                          (n) * BYTES_PER_MP_LIMB ||  \
   4.226 -+                                     (n) * MPFR_BYTES_PER_MP_LIMB ||  \
   4.227 -                         (char *) (src) >= (char *) (dst) +            \
   4.228 --                                          (n) * BYTES_PER_MP_LIMB);   \
   4.229 --          memcpy ((dst), (src), (n) * BYTES_PER_MP_LIMB);             \
   4.230 -+                                     (n) * MPFR_BYTES_PER_MP_LIMB);   \
   4.231 -+          memcpy ((dst), (src), (n) * MPFR_BYTES_PER_MP_LIMB);        \
   4.232 -         }                                                             \
   4.233 -     }                                                                 \
   4.234 -   while (0)
   4.235 ---- a/src/mpfr.h	2013-03-13 16:37:37.000000000 +0100
   4.236 -+++ b/src/mpfr.h	2014-12-31 14:56:02.687641984 +0100
   4.237 -@@ -27,7 +27,7 @@
   4.238 - #define MPFR_VERSION_MAJOR 3
   4.239 - #define MPFR_VERSION_MINOR 1
   4.240 - #define MPFR_VERSION_PATCHLEVEL 2
   4.241 --#define MPFR_VERSION_STRING "3.1.2"
   4.242 -+#define MPFR_VERSION_STRING "3.1.2-p11"
   4.243 - 
   4.244 - /* Macros dealing with MPFR VERSION */
   4.245 - #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
   4.246 -@@ -861,7 +861,7 @@
   4.247 -     _t = (mpfr_kind_t) _k;                                     \
   4.248 -     _s = 1;                                                    \
   4.249 -   } else {                                                     \
   4.250 --    _t = (mpfr_kind_t) -k;                                     \
   4.251 -+    _t = (mpfr_kind_t) - _k;                                   \
   4.252 -     _s = -1;                                                   \
   4.253 -   }                                                            \
   4.254 -   _e = _t == MPFR_REGULAR_KIND ? (e) :                         \
   4.255 ---- a/src/mpfr-impl.h	2013-03-13 16:37:36.000000000 +0100
   4.256 -+++ b/src/mpfr-impl.h	2014-12-31 14:56:02.687641984 +0100
   4.257 -@@ -191,7 +191,7 @@
   4.258 - # endif
   4.259 - #endif
   4.260 - 
   4.261 --
   4.262 -+#define MPFR_BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
   4.263 - 
   4.264 - /******************************************************
   4.265 -  ******************** Check GMP ***********************
   4.266 -@@ -468,8 +468,16 @@
   4.267 - #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
   4.268 - 
   4.269 - /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
   4.270 --   at compile time. */
   4.271 --#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
   4.272 -+   at compile time.
   4.273 -+   Clang with -fsanitize=undefined is a bit similar due to a bug:
   4.274 -+     http://llvm.org/bugs/show_bug.cgi?id=17381
   4.275 -+   but even without its sanitizer, it may be better to use the
   4.276 -+   double_zero version until IEEE 754 division by zero is properly
   4.277 -+   supported:
   4.278 -+     http://llvm.org/bugs/show_bug.cgi?id=17000
   4.279 -+*/
   4.280 -+#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \
   4.281 -+    defined(__clang__)
   4.282 - static double double_zero = 0.0;
   4.283 - # define DBL_NAN (double_zero/double_zero)
   4.284 - # define DBL_POS_INF ((double) 1.0/double_zero)
   4.285 -@@ -501,6 +509,8 @@
   4.286 -    (with Xcode 2.4.1, i.e. the latest one). */
   4.287 - #define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
   4.288 - #define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
   4.289 -+/* The DOUBLE_ISNAN(x) macro is also valid on long double x
   4.290 -+   (assuming that the compiler isn't too broken). */
   4.291 - #ifdef MPFR_NANISNAN
   4.292 - /* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
   4.293 -    The + must not be replaced by a ||. With gcc -ffast-math, NaN is
   4.294 -@@ -920,7 +930,7 @@
   4.295 - #define MPFR_SET_ALLOC_SIZE(x, n) \
   4.296 -  ( ((mp_size_t*) MPFR_MANT(x))[-1] = n)
   4.297 - #define MPFR_MALLOC_SIZE(s) \
   4.298 --  ( sizeof(mpfr_size_limb_t) + BYTES_PER_MP_LIMB * ((size_t) s) )
   4.299 -+  ( sizeof(mpfr_size_limb_t) + MPFR_BYTES_PER_MP_LIMB * ((size_t) s) )
   4.300 - #define MPFR_SET_MANT_PTR(x,p) \
   4.301 -    (MPFR_MANT(x) = (mp_limb_t*) ((mpfr_size_limb_t*) p + 1))
   4.302 - #define MPFR_GET_REAL_PTR(x) \
   4.303 -@@ -954,7 +964,7 @@
   4.304 - #endif
   4.305 - 
   4.306 - #define MPFR_TMP_LIMBS_ALLOC(N) \
   4.307 --  ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * BYTES_PER_MP_LIMB))
   4.308 -+  ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * MPFR_BYTES_PER_MP_LIMB))
   4.309 - 
   4.310 - /* temporary allocate 1 limb at xp, and initialize mpfr variable x */
   4.311 - /* The temporary var doesn't have any size field, but it doesn't matter
   4.312 ---- a/src/mul.c	2013-03-13 16:37:37.000000000 +0100
   4.313 -+++ b/src/mul.c	2014-12-31 14:56:02.688641997 +0100
   4.314 -@@ -106,7 +106,7 @@
   4.315 -   MPFR_ASSERTD(tn <= k);
   4.316 - 
   4.317 -   /* Check for no size_t overflow*/
   4.318 --  MPFR_ASSERTD((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
   4.319 -+  MPFR_ASSERTD((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
   4.320 -   MPFR_TMP_MARK(marker);
   4.321 -   tmp = MPFR_TMP_LIMBS_ALLOC (k);
   4.322 - 
   4.323 -@@ -301,7 +301,7 @@
   4.324 -   MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */
   4.325 - 
   4.326 -   /* Check for no size_t overflow*/
   4.327 --  MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
   4.328 -+  MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
   4.329 -   MPFR_TMP_MARK (marker);
   4.330 -   tmp = MPFR_TMP_LIMBS_ALLOC (k);
   4.331 - 
   4.332 ---- a/src/stack_interface.c	2013-03-13 16:37:32.000000000 +0100
   4.333 -+++ b/src/stack_interface.c	2014-12-31 14:56:02.688641997 +0100
   4.334 -@@ -26,7 +26,7 @@
   4.335 - size_t
   4.336 - mpfr_custom_get_size (mpfr_prec_t prec)
   4.337 - {
   4.338 --  return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB;
   4.339 -+  return MPFR_PREC2LIMBS (prec) * MPFR_BYTES_PER_MP_LIMB;
   4.340 - }
   4.341 - 
   4.342 - #undef mpfr_custom_init
   4.343 ---- a/src/strtofr.c	2013-03-13 16:37:32.000000000 +0100
   4.344 -+++ b/src/strtofr.c	2014-12-31 14:56:02.688641997 +0100
   4.345 -@@ -473,8 +473,10 @@
   4.346 -       /* prec bits corresponds to ysize limbs */
   4.347 -       ysize_bits = ysize * GMP_NUMB_BITS;
   4.348 -       /* and to ysize_bits >= prec > MPFR_PREC (x) bits */
   4.349 --      y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 1);
   4.350 --      y += ysize; /* y has (ysize+1) allocated limbs */
   4.351 -+      /* we need to allocate one more limb to work around bug
   4.352 -+         https://gmplib.org/list-archives/gmp-bugs/2013-December/003267.html */
   4.353 -+      y = MPFR_TMP_LIMBS_ALLOC (2 * ysize + 2);
   4.354 -+      y += ysize; /* y has (ysize+2) allocated limbs */
   4.355 - 
   4.356 -       /* pstr_size is the number of characters we read in pstr->mant
   4.357 -          to have at least ysize full limbs.
   4.358 ---- a/src/vasprintf.c	2013-03-13 16:37:37.000000000 +0100
   4.359 -+++ b/src/vasprintf.c	2014-12-31 14:56:02.688641997 +0100
   4.360 -@@ -884,14 +884,18 @@
   4.361 -            first digit, we want the exponent for radix two and the decimal
   4.362 -            point AFTER the first digit. */
   4.363 -         {
   4.364 --          MPFR_ASSERTN (exp > MPFR_EMIN_MIN /4); /* possible overflow */
   4.365 -+          /* An integer overflow is normally not possible since MPFR_EXP_MIN
   4.366 -+             is twice as large as MPFR_EMIN_MIN. */
   4.367 -+          MPFR_ASSERTN (exp > (MPFR_EXP_MIN + 3) / 4);
   4.368 -           exp = (exp - 1) * 4;
   4.369 -         }
   4.370 -       else
   4.371 -         /* EXP is the exponent for decimal point BEFORE the first digit, we
   4.372 -            want the exponent for decimal point AFTER the first digit. */
   4.373 -         {
   4.374 --          MPFR_ASSERTN (exp > MPFR_EMIN_MIN); /* possible overflow */
   4.375 -+          /* An integer overflow is normally not possible since MPFR_EXP_MIN
   4.376 -+             is twice as large as MPFR_EMIN_MIN. */
   4.377 -+          MPFR_ASSERTN (exp > MPFR_EXP_MIN);
   4.378 -           --exp;
   4.379 -         }
   4.380 -     }
   4.381 -@@ -1040,7 +1044,7 @@
   4.382 - }
   4.383 - 
   4.384 - /* Determine the different parts of the string representation of the regular
   4.385 --   number P when SPEC.SPEC is 'e', 'E', 'g', or 'G'.
   4.386 -+   number P when spec.spec is 'e', 'E', 'g', or 'G'.
   4.387 -    DEC_INFO contains the previously computed exponent and string or is NULL.
   4.388 - 
   4.389 -    return -1 if some field > INT_MAX */
   4.390 -@@ -1167,7 +1171,7 @@
   4.391 - }
   4.392 - 
   4.393 - /* Determine the different parts of the string representation of the regular
   4.394 --   number P when SPEC.SPEC is 'f', 'F', 'g', or 'G'.
   4.395 -+   number P when spec.spec is 'f', 'F', 'g', or 'G'.
   4.396 -    DEC_INFO contains the previously computed exponent and string or is NULL.
   4.397 - 
   4.398 -    return -1 if some field of number_parts is greater than INT_MAX */
   4.399 -@@ -1559,7 +1563,7 @@
   4.400 -             /* fractional part */
   4.401 -             {
   4.402 -               np->point = MPFR_DECIMAL_POINT;
   4.403 --              np->fp_trailing_zeros = (spec.spec == 'g' && spec.spec == 'G') ?
   4.404 -+              np->fp_trailing_zeros = (spec.spec == 'g' || spec.spec == 'G') ?
   4.405 -                 spec.prec - 1 : spec.prec;
   4.406 -             }
   4.407 -           else if (spec.alt)
   4.408 ---- a/src/version.c	2013-03-13 16:37:34.000000000 +0100
   4.409 -+++ b/src/version.c	2014-12-31 14:56:02.688641997 +0100
   4.410 -@@ -25,5 +25,5 @@
   4.411 - const char *
   4.412 - mpfr_get_version (void)
   4.413 - {
   4.414 --  return "3.1.2";
   4.415 -+  return "3.1.2-p11";
   4.416 - }
   4.417 ---- a/tests/tdiv.c	2013-03-13 16:37:44.000000000 +0100
   4.418 -+++ b/tests/tdiv.c	2014-12-31 14:56:02.689642010 +0100
   4.419 -@@ -1104,6 +1104,96 @@
   4.420 - #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
   4.421 - #include "tgeneric.c"
   4.422 - 
   4.423 -+static void
   4.424 -+test_extreme (void)
   4.425 -+{
   4.426 -+  mpfr_t x, y, z;
   4.427 -+  mpfr_exp_t emin, emax;
   4.428 -+  mpfr_prec_t p[4] = { 8, 32, 64, 256 };
   4.429 -+  int xi, yi, zi, j, r;
   4.430 -+  unsigned int flags, ex_flags;
   4.431 -+
   4.432 -+  emin = mpfr_get_emin ();
   4.433 -+  emax = mpfr_get_emax ();
   4.434 -+
   4.435 -+  mpfr_set_emin (MPFR_EMIN_MIN);
   4.436 -+  mpfr_set_emax (MPFR_EMAX_MAX);
   4.437 -+
   4.438 -+  for (xi = 0; xi < 4; xi++)
   4.439 -+    {
   4.440 -+      mpfr_init2 (x, p[xi]);
   4.441 -+      mpfr_setmax (x, MPFR_EMAX_MAX);
   4.442 -+      MPFR_ASSERTN (mpfr_check (x));
   4.443 -+      for (yi = 0; yi < 4; yi++)
   4.444 -+        {
   4.445 -+          mpfr_init2 (y, p[yi]);
   4.446 -+          mpfr_setmin (y, MPFR_EMIN_MIN);
   4.447 -+          for (j = 0; j < 2; j++)
   4.448 -+            {
   4.449 -+              MPFR_ASSERTN (mpfr_check (y));
   4.450 -+              for (zi = 0; zi < 4; zi++)
   4.451 -+                {
   4.452 -+                  mpfr_init2 (z, p[zi]);
   4.453 -+                  RND_LOOP (r)
   4.454 -+                    {
   4.455 -+                      mpfr_clear_flags ();
   4.456 -+                      mpfr_div (z, x, y, (mpfr_rnd_t) r);
   4.457 -+                      flags = __gmpfr_flags;
   4.458 -+                      MPFR_ASSERTN (mpfr_check (z));
   4.459 -+                      ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
   4.460 -+                      if (flags != ex_flags)
   4.461 -+                        {
   4.462 -+                          printf ("Bad flags in test_extreme on z = a/b"
   4.463 -+                                  " with %s and\n",
   4.464 -+                                  mpfr_print_rnd_mode ((mpfr_rnd_t) r));
   4.465 -+                          printf ("a = ");
   4.466 -+                          mpfr_dump (x);
   4.467 -+                          printf ("b = ");
   4.468 -+                          mpfr_dump (y);
   4.469 -+                          printf ("Expected flags:");
   4.470 -+                          flags_out (ex_flags);
   4.471 -+                          printf ("Got flags:     ");
   4.472 -+                          flags_out (flags);
   4.473 -+                          printf ("z = ");
   4.474 -+                          mpfr_dump (z);
   4.475 -+                          exit (1);
   4.476 -+                        }
   4.477 -+                      mpfr_clear_flags ();
   4.478 -+                      mpfr_div (z, y, x, (mpfr_rnd_t) r);
   4.479 -+                      flags = __gmpfr_flags;
   4.480 -+                      MPFR_ASSERTN (mpfr_check (z));
   4.481 -+                      ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
   4.482 -+                      if (flags != ex_flags)
   4.483 -+                        {
   4.484 -+                          printf ("Bad flags in test_extreme on z = a/b"
   4.485 -+                                  " with %s and\n",
   4.486 -+                                  mpfr_print_rnd_mode ((mpfr_rnd_t) r));
   4.487 -+                          printf ("a = ");
   4.488 -+                          mpfr_dump (y);
   4.489 -+                          printf ("b = ");
   4.490 -+                          mpfr_dump (x);
   4.491 -+                          printf ("Expected flags:");
   4.492 -+                          flags_out (ex_flags);
   4.493 -+                          printf ("Got flags:     ");
   4.494 -+                          flags_out (flags);
   4.495 -+                          printf ("z = ");
   4.496 -+                          mpfr_dump (z);
   4.497 -+                          exit (1);
   4.498 -+                        }
   4.499 -+                    }
   4.500 -+                  mpfr_clear (z);
   4.501 -+                }  /* zi */
   4.502 -+              mpfr_nextabove (y);
   4.503 -+            }  /* j */
   4.504 -+          mpfr_clear (y);
   4.505 -+        }  /* yi */
   4.506 -+      mpfr_clear (x);
   4.507 -+    }  /* xi */
   4.508 -+
   4.509 -+  set_emin (emin);
   4.510 -+  set_emax (emax);
   4.511 -+}
   4.512 -+
   4.513 - int
   4.514 - main (int argc, char *argv[])
   4.515 - {
   4.516 -@@ -1130,6 +1220,7 @@
   4.517 -   test_20070603 ();
   4.518 -   test_20070628 ();
   4.519 -   test_generic (2, 800, 50);
   4.520 -+  test_extreme ();
   4.521 - 
   4.522 -   tests_end_mpfr ();
   4.523 -   return 0;
   4.524 ---- a/tests/texp.c	2013-03-13 16:37:44.000000000 +0100
   4.525 -+++ b/tests/texp.c	2014-12-31 14:56:02.689642010 +0100
   4.526 -@@ -150,6 +150,22 @@
   4.527 -       exit (1);
   4.528 -     }
   4.529 - 
   4.530 -+  mpfr_set_prec (x, 118);
   4.531 -+  mpfr_set_str_binary (x, "0.1110010100011101010000111110011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E-86");
   4.532 -+  mpfr_set_prec (y, 118);
   4.533 -+  mpfr_exp_2 (y, x, MPFR_RNDU);
   4.534 -+  mpfr_exp_3 (x, x, MPFR_RNDU);
   4.535 -+  if (mpfr_cmp (x, y))
   4.536 -+    {
   4.537 -+      printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=118\n");
   4.538 -+      printf ("mpfr_exp_2 gives ");
   4.539 -+      mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
   4.540 -+      printf ("\nmpfr_exp_3 gives ");
   4.541 -+      mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
   4.542 -+      printf ("\n");
   4.543 -+      exit (1);
   4.544 -+    }
   4.545 -+
   4.546 -   mpfr_clear (x);
   4.547 -   mpfr_clear (y);
   4.548 -   return 0;
   4.549 ---- a/tests/tfits.c	2013-03-13 16:37:45.000000000 +0100
   4.550 -+++ b/tests/tfits.c	2014-12-31 14:56:02.689642010 +0100
   4.551 -@@ -33,155 +33,176 @@
   4.552 - #include "mpfr-intmax.h"
   4.553 - #include "mpfr-test.h"
   4.554 - 
   4.555 --#define ERROR1 { printf("Initial error for x="); mpfr_dump(x); exit(1); }
   4.556 --#define ERROR2 { printf("Error for x="); mpfr_dump(x); exit(1); }
   4.557 -+#define ERROR1(N)                                               \
   4.558 -+  do                                                            \
   4.559 -+    {                                                           \
   4.560 -+      printf("Error %d for rnd = %s and x = ", N,               \
   4.561 -+             mpfr_print_rnd_mode ((mpfr_rnd_t) r));             \
   4.562 -+      mpfr_dump(x);                                             \
   4.563 -+      exit(1);                                                  \
   4.564 -+    }                                                           \
   4.565 -+  while (0)
   4.566 - 
   4.567 - static void check_intmax (void);
   4.568 - 
   4.569 - int
   4.570 - main (void)
   4.571 - {
   4.572 --  mpfr_t x;
   4.573 -+  mpfr_t x, y;
   4.574 -+  int i, r;
   4.575 - 
   4.576 -   tests_start_mpfr ();
   4.577 - 
   4.578 -   mpfr_init2 (x, 256);
   4.579 -+  mpfr_init2 (y, 8);
   4.580 - 
   4.581 --  /* Check NAN */
   4.582 --  mpfr_set_nan (x);
   4.583 --  if (mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.584 --    ERROR1;
   4.585 --  if (mpfr_fits_slong_p (x, MPFR_RNDN))
   4.586 --    ERROR1;
   4.587 --  if (mpfr_fits_uint_p (x, MPFR_RNDN))
   4.588 --    ERROR1;
   4.589 --  if (mpfr_fits_sint_p (x, MPFR_RNDN))
   4.590 --    ERROR1;
   4.591 --  if (mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.592 --    ERROR1;
   4.593 --  if (mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.594 --    ERROR1;
   4.595 --
   4.596 --  /* Check INF */
   4.597 --  mpfr_set_inf (x, 1);
   4.598 --  if (mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.599 --    ERROR1;
   4.600 --  if (mpfr_fits_slong_p (x, MPFR_RNDN))
   4.601 --    ERROR1;
   4.602 --  if (mpfr_fits_uint_p (x, MPFR_RNDN))
   4.603 --    ERROR1;
   4.604 --  if (mpfr_fits_sint_p (x, MPFR_RNDN))
   4.605 --    ERROR1;
   4.606 --  if (mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.607 --    ERROR1;
   4.608 --  if (mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.609 --    ERROR1;
   4.610 --
   4.611 --  /* Check Zero */
   4.612 --  MPFR_SET_ZERO (x);
   4.613 --  if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.614 --    ERROR2;
   4.615 --  if (!mpfr_fits_slong_p (x, MPFR_RNDN))
   4.616 --    ERROR2;
   4.617 --  if (!mpfr_fits_uint_p (x, MPFR_RNDN))
   4.618 --    ERROR2;
   4.619 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.620 --    ERROR2;
   4.621 --  if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.622 --    ERROR2;
   4.623 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.624 --    ERROR2;
   4.625 --
   4.626 --  /* Check small op */
   4.627 --  mpfr_set_str1 (x, "1@-1");
   4.628 --  if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.629 --    ERROR2;
   4.630 --  if (!mpfr_fits_slong_p (x, MPFR_RNDN))
   4.631 --    ERROR2;
   4.632 --  if (!mpfr_fits_uint_p (x, MPFR_RNDN))
   4.633 --    ERROR2;
   4.634 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.635 --    ERROR2;
   4.636 --  if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.637 --    ERROR2;
   4.638 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.639 --    ERROR2;
   4.640 --
   4.641 --  /* Check 17 */
   4.642 --  mpfr_set_ui (x, 17, MPFR_RNDN);
   4.643 --  if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.644 --    ERROR2;
   4.645 --  if (!mpfr_fits_slong_p (x, MPFR_RNDN))
   4.646 --    ERROR2;
   4.647 --  if (!mpfr_fits_uint_p (x, MPFR_RNDN))
   4.648 --    ERROR2;
   4.649 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.650 --    ERROR2;
   4.651 --  if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.652 --    ERROR2;
   4.653 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.654 --    ERROR2;
   4.655 --
   4.656 --  /* Check all other values */
   4.657 --  mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
   4.658 --  mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
   4.659 --  if (mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.660 --    ERROR1;
   4.661 --  if (mpfr_fits_slong_p (x, MPFR_RNDN))
   4.662 --    ERROR1;
   4.663 --  mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
   4.664 --  if (mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.665 --    ERROR1;
   4.666 --  if (mpfr_fits_uint_p (x, MPFR_RNDN))
   4.667 --    ERROR1;
   4.668 --  if (mpfr_fits_sint_p (x, MPFR_RNDN))
   4.669 --    ERROR1;
   4.670 --  if (mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.671 --    ERROR1;
   4.672 --  if (mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.673 --    ERROR1;
   4.674 --
   4.675 --  mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
   4.676 --  if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.677 --    ERROR2;
   4.678 --  mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
   4.679 --  if (!mpfr_fits_slong_p (x, MPFR_RNDN))
   4.680 --    ERROR2;
   4.681 --  mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
   4.682 --  if (!mpfr_fits_uint_p (x, MPFR_RNDN))
   4.683 --    ERROR2;
   4.684 --  mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
   4.685 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.686 --    ERROR2;
   4.687 --  mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
   4.688 --  if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.689 --    ERROR2;
   4.690 --  mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
   4.691 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.692 --    ERROR2;
   4.693 --
   4.694 --  mpfr_set_si (x, 1, MPFR_RNDN);
   4.695 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.696 --    ERROR2;
   4.697 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.698 --    ERROR2;
   4.699 --
   4.700 --  /* Check negative value */
   4.701 --  mpfr_set_si (x, -1, MPFR_RNDN);
   4.702 --  if (!mpfr_fits_sint_p (x, MPFR_RNDN))
   4.703 --    ERROR2;
   4.704 --  if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
   4.705 --    ERROR2;
   4.706 --  if (!mpfr_fits_slong_p (x, MPFR_RNDN))
   4.707 --    ERROR2;
   4.708 --  if (mpfr_fits_uint_p (x, MPFR_RNDN))
   4.709 --    ERROR1;
   4.710 --  if (mpfr_fits_ushort_p (x, MPFR_RNDN))
   4.711 --    ERROR1;
   4.712 --  if (mpfr_fits_ulong_p (x, MPFR_RNDN))
   4.713 --    ERROR1;
   4.714 -+  RND_LOOP (r)
   4.715 -+    {
   4.716 -+
   4.717 -+      /* Check NAN */
   4.718 -+      mpfr_set_nan (x);
   4.719 -+      if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.720 -+        ERROR1 (1);
   4.721 -+      if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.722 -+        ERROR1 (2);
   4.723 -+      if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.724 -+        ERROR1 (3);
   4.725 -+      if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.726 -+        ERROR1 (4);
   4.727 -+      if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.728 -+        ERROR1 (5);
   4.729 -+      if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.730 -+        ERROR1 (6);
   4.731 -+
   4.732 -+      /* Check INF */
   4.733 -+      mpfr_set_inf (x, 1);
   4.734 -+      if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.735 -+        ERROR1 (7);
   4.736 -+      if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.737 -+        ERROR1 (8);
   4.738 -+      if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.739 -+        ERROR1 (9);
   4.740 -+      if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.741 -+        ERROR1 (10);
   4.742 -+      if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.743 -+        ERROR1 (11);
   4.744 -+      if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.745 -+        ERROR1 (12);
   4.746 -+
   4.747 -+      /* Check Zero */
   4.748 -+      MPFR_SET_ZERO (x);
   4.749 -+      if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.750 -+        ERROR1 (13);
   4.751 -+      if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.752 -+        ERROR1 (14);
   4.753 -+      if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.754 -+        ERROR1 (15);
   4.755 -+      if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.756 -+        ERROR1 (16);
   4.757 -+      if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.758 -+        ERROR1 (17);
   4.759 -+      if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.760 -+        ERROR1 (18);
   4.761 -+
   4.762 -+      /* Check small positive op */
   4.763 -+      mpfr_set_str1 (x, "1@-1");
   4.764 -+      if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.765 -+        ERROR1 (19);
   4.766 -+      if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.767 -+        ERROR1 (20);
   4.768 -+      if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.769 -+        ERROR1 (21);
   4.770 -+      if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.771 -+        ERROR1 (22);
   4.772 -+      if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.773 -+        ERROR1 (23);
   4.774 -+      if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.775 -+        ERROR1 (24);
   4.776 -+
   4.777 -+      /* Check 17 */
   4.778 -+      mpfr_set_ui (x, 17, MPFR_RNDN);
   4.779 -+      if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.780 -+        ERROR1 (25);
   4.781 -+      if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.782 -+        ERROR1 (26);
   4.783 -+      if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.784 -+        ERROR1 (27);
   4.785 -+      if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.786 -+        ERROR1 (28);
   4.787 -+      if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.788 -+        ERROR1 (29);
   4.789 -+      if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.790 -+        ERROR1 (30);
   4.791 -+
   4.792 -+      /* Check all other values */
   4.793 -+      mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
   4.794 -+      mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
   4.795 -+      if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.796 -+        ERROR1 (31);
   4.797 -+      if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.798 -+        ERROR1 (32);
   4.799 -+      mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
   4.800 -+      if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.801 -+        ERROR1 (33);
   4.802 -+      if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.803 -+        ERROR1 (34);
   4.804 -+      if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.805 -+        ERROR1 (35);
   4.806 -+      if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.807 -+        ERROR1 (36);
   4.808 -+      if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.809 -+        ERROR1 (37);
   4.810 -+
   4.811 -+      mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
   4.812 -+      if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
   4.813 -+        ERROR1 (38);
   4.814 -+      mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
   4.815 -+      if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.816 -+        ERROR1 (39);
   4.817 -+      mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
   4.818 -+      if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
   4.819 -+        ERROR1 (40);
   4.820 -+      mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
   4.821 -+      if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.822 -+        ERROR1 (41);
   4.823 -+      mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
   4.824 -+      if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
   4.825 -+        ERROR1 (42);
   4.826 -+      mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
   4.827 -+      if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.828 -+        ERROR1 (43);
   4.829 -+
   4.830 -+      mpfr_set_si (x, 1, MPFR_RNDN);
   4.831 -+      if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.832 -+        ERROR1 (44);
   4.833 -+      if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.834 -+        ERROR1 (45);
   4.835 -+
   4.836 -+      /* Check negative op */
   4.837 -+      for (i = 1; i <= 4; i++)
   4.838 -+        {
   4.839 -+          int inv;
   4.840 -+
   4.841 -+          mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
   4.842 -+          mpfr_rint (y, x, (mpfr_rnd_t) r);
   4.843 -+          inv = MPFR_NOTZERO (y);
   4.844 -+          if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r) ^ inv)
   4.845 -+            ERROR1 (46);
   4.846 -+          if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
   4.847 -+            ERROR1 (47);
   4.848 -+          if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r) ^ inv)
   4.849 -+            ERROR1 (48);
   4.850 -+          if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
   4.851 -+            ERROR1 (49);
   4.852 -+          if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r) ^ inv)
   4.853 -+            ERROR1 (50);
   4.854 -+          if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
   4.855 -+            ERROR1 (51);
   4.856 -+        }
   4.857 -+    }
   4.858 - 
   4.859 -   mpfr_clear (x);
   4.860 -+  mpfr_clear (y);
   4.861 - 
   4.862 -   check_intmax ();
   4.863 - 
   4.864 -@@ -189,85 +210,98 @@
   4.865 -   return 0;
   4.866 - }
   4.867 - 
   4.868 --static void check_intmax (void)
   4.869 -+static void
   4.870 -+check_intmax (void)
   4.871 - {
   4.872 - #ifdef _MPFR_H_HAVE_INTMAX_T
   4.873 --  mpfr_t x;
   4.874 -+  mpfr_t x, y;
   4.875 -+  int i, r;
   4.876 - 
   4.877 --  mpfr_init2 (x, sizeof (uintmax_t)*CHAR_BIT);
   4.878 -+  mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT);
   4.879 -+  mpfr_init2 (y, 8);
   4.880 - 
   4.881 --  /* Check NAN */
   4.882 --  mpfr_set_nan (x);
   4.883 --  if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.884 --    ERROR1;
   4.885 --  if (mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.886 --    ERROR1;
   4.887 --
   4.888 --  /* Check INF */
   4.889 --  mpfr_set_inf (x, 1);
   4.890 --  if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.891 --    ERROR1;
   4.892 --  if (mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.893 --    ERROR1;
   4.894 --
   4.895 --  /* Check Zero */
   4.896 --  MPFR_SET_ZERO (x);
   4.897 --  if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.898 --    ERROR2;
   4.899 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.900 --    ERROR2;
   4.901 --
   4.902 --  /* Check small op */
   4.903 --  mpfr_set_str1 (x, "1@-1");
   4.904 --  if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.905 --    ERROR2;
   4.906 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.907 --    ERROR2;
   4.908 --
   4.909 --  /* Check 17 */
   4.910 --  mpfr_set_ui (x, 17, MPFR_RNDN);
   4.911 --  if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.912 --    ERROR2;
   4.913 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.914 --    ERROR2;
   4.915 --
   4.916 --  /* Check hugest */
   4.917 --  mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
   4.918 --  if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.919 --    ERROR1;
   4.920 --  if (mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.921 --    ERROR1;
   4.922 --
   4.923 --  /* Check all other values */
   4.924 --  mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
   4.925 --  mpfr_add_ui (x, x, 1, MPFR_RNDN);
   4.926 --  if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.927 --    ERROR1;
   4.928 --  mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
   4.929 --  if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.930 --    ERROR2;
   4.931 --  mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
   4.932 --  mpfr_add_ui (x, x, 1, MPFR_RNDN);
   4.933 --  if (mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.934 --    ERROR1;
   4.935 --  mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
   4.936 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.937 --    ERROR2;
   4.938 --  mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
   4.939 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.940 --    ERROR2;
   4.941 --  mpfr_sub_ui (x, x, 1, MPFR_RNDN);
   4.942 --  if (mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.943 --    ERROR1;
   4.944 --
   4.945 --  /* Check negative value */
   4.946 --  mpfr_set_si (x, -1, MPFR_RNDN);
   4.947 --  if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
   4.948 --    ERROR2;
   4.949 --  if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
   4.950 --    ERROR1;
   4.951 -+  RND_LOOP (r)
   4.952 -+    {
   4.953 -+      /* Check NAN */
   4.954 -+      mpfr_set_nan (x);
   4.955 -+      if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.956 -+        ERROR1 (52);
   4.957 -+      if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.958 -+        ERROR1 (53);
   4.959 -+
   4.960 -+      /* Check INF */
   4.961 -+      mpfr_set_inf (x, 1);
   4.962 -+      if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.963 -+        ERROR1 (54);
   4.964 -+      if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.965 -+        ERROR1 (55);
   4.966 -+
   4.967 -+      /* Check Zero */
   4.968 -+      MPFR_SET_ZERO (x);
   4.969 -+      if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.970 -+        ERROR1 (56);
   4.971 -+      if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.972 -+        ERROR1 (57);
   4.973 -+
   4.974 -+      /* Check positive small op */
   4.975 -+      mpfr_set_str1 (x, "1@-1");
   4.976 -+      if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.977 -+        ERROR1 (58);
   4.978 -+      if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.979 -+        ERROR1 (59);
   4.980 -+
   4.981 -+      /* Check 17 */
   4.982 -+      mpfr_set_ui (x, 17, MPFR_RNDN);
   4.983 -+      if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.984 -+        ERROR1 (60);
   4.985 -+      if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.986 -+        ERROR1 (61);
   4.987 -+
   4.988 -+      /* Check hugest */
   4.989 -+      mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
   4.990 -+      if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.991 -+        ERROR1 (62);
   4.992 -+      if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
   4.993 -+        ERROR1 (63);
   4.994 -+
   4.995 -+      /* Check all other values */
   4.996 -+      mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
   4.997 -+      mpfr_add_ui (x, x, 1, MPFR_RNDN);
   4.998 -+      if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
   4.999 -+        ERROR1 (64);
  4.1000 -+      mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
  4.1001 -+      if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
  4.1002 -+        ERROR1 (65);
  4.1003 -+      mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
  4.1004 -+      mpfr_add_ui (x, x, 1, MPFR_RNDN);
  4.1005 -+      if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
  4.1006 -+        ERROR1 (66);
  4.1007 -+      mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
  4.1008 -+      if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
  4.1009 -+        ERROR1 (67);
  4.1010 -+      mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
  4.1011 -+      if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
  4.1012 -+        ERROR1 (68);
  4.1013 -+      mpfr_sub_ui (x, x, 1, MPFR_RNDN);
  4.1014 -+      if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
  4.1015 -+        ERROR1 (69);
  4.1016 -+
  4.1017 -+      /* Check negative op */
  4.1018 -+      for (i = 1; i <= 4; i++)
  4.1019 -+        {
  4.1020 -+          int inv;
  4.1021 -+
  4.1022 -+          mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
  4.1023 -+          mpfr_rint (y, x, (mpfr_rnd_t) r);
  4.1024 -+          inv = MPFR_NOTZERO (y);
  4.1025 -+          if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv)
  4.1026 -+            ERROR1 (70);
  4.1027 -+          if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
  4.1028 -+            ERROR1 (71);
  4.1029 -+        }
  4.1030 -+    }
  4.1031 - 
  4.1032 -   mpfr_clear (x);
  4.1033 -+  mpfr_clear (y);
  4.1034 - #endif
  4.1035 - }
  4.1036 --
  4.1037 ---- a/tests/tget_flt.c	2013-03-13 16:37:44.000000000 +0100
  4.1038 -+++ b/tests/tget_flt.c	2014-12-31 14:56:02.690642023 +0100
  4.1039 -@@ -28,9 +28,17 @@
  4.1040 - main (void)
  4.1041 - {
  4.1042 -   mpfr_t x, y;
  4.1043 --  float f, g, infp;
  4.1044 -+  float f, g;
  4.1045 -   int i;
  4.1046 -+#if !defined(MPFR_ERRDIVZERO)
  4.1047 -+  float infp;
  4.1048 -+#endif
  4.1049 - 
  4.1050 -+  tests_start_mpfr ();
  4.1051 -+
  4.1052 -+#if !defined(MPFR_ERRDIVZERO)
  4.1053 -+  /* The definition of DBL_POS_INF involves a division by 0. This makes
  4.1054 -+     "clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
  4.1055 -   infp = (float) DBL_POS_INF;
  4.1056 -   if (infp * 0.5 != infp)
  4.1057 -     {
  4.1058 -@@ -38,8 +46,7 @@
  4.1059 -       fprintf (stderr, "(this is probably a compiler bug, please report)\n");
  4.1060 -       exit (1);
  4.1061 -     }
  4.1062 --
  4.1063 --  tests_start_mpfr ();
  4.1064 -+#endif
  4.1065 - 
  4.1066 -   mpfr_init2 (x, 24);
  4.1067 -   mpfr_init2 (y, 24);
  4.1068 -@@ -353,6 +360,7 @@
  4.1069 -       printf ("expected %.8e, got %.8e\n", g, f);
  4.1070 -       exit (1);
  4.1071 -     }
  4.1072 -+#if !defined(MPFR_ERRDIVZERO)
  4.1073 -   f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
  4.1074 -                                       thus we should get +Inf */
  4.1075 -   g = infp;
  4.1076 -@@ -376,6 +384,7 @@
  4.1077 -       printf ("expected %.8e, got %.8e\n", g, f);
  4.1078 -       exit (1);
  4.1079 -     }
  4.1080 -+#endif
  4.1081 - 
  4.1082 -   mpfr_clear (x);
  4.1083 -   mpfr_clear (y);
  4.1084 ---- a/tests/tset_ld.c	2013-03-13 16:37:44.000000000 +0100
  4.1085 -+++ b/tests/tset_ld.c	2014-12-31 14:56:02.690642023 +0100
  4.1086 -@@ -47,8 +47,11 @@
  4.1087 - static int
  4.1088 - Isnan_ld (long double d)
  4.1089 - {
  4.1090 --  double e = (double) d;
  4.1091 --  if (DOUBLE_ISNAN (e))
  4.1092 -+  /* Do not convert d to double as this can give an overflow, which
  4.1093 -+     may confuse compilers without IEEE 754 support (such as clang
  4.1094 -+     -fsanitize=undefined), or trigger a trap if enabled.
  4.1095 -+     The DOUBLE_ISNAN macro should work fine on long double. */
  4.1096 -+  if (DOUBLE_ISNAN (d))
  4.1097 -     return 1;
  4.1098 -   LONGDOUBLE_NAN_ACTION (d, goto yes);
  4.1099 -   return 0;
  4.1100 ---- a/tests/tsprintf.c	2013-03-13 16:37:44.000000000 +0100
  4.1101 -+++ b/tests/tsprintf.c	2014-12-31 14:56:02.690642023 +0100
  4.1102 -@@ -456,10 +456,16 @@
  4.1103 -   check_sprintf ("1.999900  ", "%-#10.7RG", x);
  4.1104 -   check_sprintf ("1.9999    ", "%-10.7RG", x);
  4.1105 -   mpfr_set_ui (x, 1, MPFR_RNDN);
  4.1106 -+  check_sprintf ("1.", "%#.1Rg", x);
  4.1107 -+  check_sprintf ("1.   ", "%-#5.1Rg", x);
  4.1108 -+  check_sprintf ("  1.0", "%#5.2Rg", x);
  4.1109 -   check_sprintf ("1.00000000000000000000000000000", "%#.30Rg", x);
  4.1110 -   check_sprintf ("1", "%.30Rg", x);
  4.1111 -   mpfr_set_ui (x, 0, MPFR_RNDN);
  4.1112 --  check_sprintf ("0.000000000000000000000000000000", "%#.30Rg", x);
  4.1113 -+  check_sprintf ("0.", "%#.1Rg", x);
  4.1114 -+  check_sprintf ("0.   ", "%-#5.1Rg", x);
  4.1115 -+  check_sprintf ("  0.0", "%#5.2Rg", x);
  4.1116 -+  check_sprintf ("0.00000000000000000000000000000", "%#.30Rg", x);
  4.1117 -   check_sprintf ("0", "%.30Rg", x);
  4.1118 - 
  4.1119 -   /* following tests with precision 53 bits */
  4.1120 -@@ -1178,6 +1184,69 @@
  4.1121 -   check_emax_aux (MPFR_EMAX_MAX);
  4.1122 - }
  4.1123 - 
  4.1124 -+static void
  4.1125 -+check_emin_aux (mpfr_exp_t e)
  4.1126 -+{
  4.1127 -+  mpfr_t x;
  4.1128 -+  char *s1, s2[256];
  4.1129 -+  int i;
  4.1130 -+  mpfr_exp_t emin;
  4.1131 -+  mpz_t ee;
  4.1132 -+
  4.1133 -+  MPFR_ASSERTN (e >= LONG_MIN);
  4.1134 -+  emin = mpfr_get_emin ();
  4.1135 -+  set_emin (e);
  4.1136 -+
  4.1137 -+  mpfr_init2 (x, 16);
  4.1138 -+  mpz_init (ee);
  4.1139 -+
  4.1140 -+  mpfr_setmin (x, e);
  4.1141 -+  mpz_set_si (ee, e);
  4.1142 -+  mpz_sub_ui (ee, ee, 1);
  4.1143 -+
  4.1144 -+  i = mpfr_asprintf (&s1, "%Ra", x);
  4.1145 -+  MPFR_ASSERTN (i > 0);
  4.1146 -+
  4.1147 -+  gmp_snprintf (s2, 256, "0x1p%Zd", ee);
  4.1148 -+
  4.1149 -+  if (strcmp (s1, s2) != 0)
  4.1150 -+    {
  4.1151 -+      printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
  4.1152 -+      printf ("Expected %s\n", s2);
  4.1153 -+      printf ("Got      %s\n", s1);
  4.1154 -+      exit (1);
  4.1155 -+    }
  4.1156 -+
  4.1157 -+  mpfr_free_str (s1);
  4.1158 -+
  4.1159 -+  i = mpfr_asprintf (&s1, "%Rb", x);
  4.1160 -+  MPFR_ASSERTN (i > 0);
  4.1161 -+
  4.1162 -+  gmp_snprintf (s2, 256, "1p%Zd", ee);
  4.1163 -+
  4.1164 -+  if (strcmp (s1, s2) != 0)
  4.1165 -+    {
  4.1166 -+      printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
  4.1167 -+      printf ("Expected %s\n", s2);
  4.1168 -+      printf ("Got      %s\n", s1);
  4.1169 -+      exit (1);
  4.1170 -+    }
  4.1171 -+
  4.1172 -+  mpfr_free_str (s1);
  4.1173 -+
  4.1174 -+  mpfr_clear (x);
  4.1175 -+  mpz_clear (ee);
  4.1176 -+  set_emin (emin);
  4.1177 -+}
  4.1178 -+
  4.1179 -+static void
  4.1180 -+check_emin (void)
  4.1181 -+{
  4.1182 -+  check_emin_aux (-15);
  4.1183 -+  check_emin_aux (mpfr_get_emin ());
  4.1184 -+  check_emin_aux (MPFR_EMIN_MIN);
  4.1185 -+}
  4.1186 -+
  4.1187 - int
  4.1188 - main (int argc, char **argv)
  4.1189 - {
  4.1190 -@@ -1197,6 +1266,7 @@
  4.1191 -   decimal ();
  4.1192 -   mixed ();
  4.1193 -   check_emax ();
  4.1194 -+  check_emin ();
  4.1195 - 
  4.1196 - #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
  4.1197 -   locale_da_DK ();
  4.1198 ---- a/VERSION	2013-03-13 16:37:28.000000000 +0100
  4.1199 -+++ b/VERSION	2014-12-31 14:56:02.690642023 +0100
  4.1200 -@@ -1 +1 @@
  4.1201 --3.1.2
  4.1202 -+3.1.2-p11