summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'dev-libs/mpfr')
-rw-r--r--dev-libs/mpfr/Manifest7
-rw-r--r--dev-libs/mpfr/files/2.4.2/patch01184
-rw-r--r--dev-libs/mpfr/files/2.4.2/patch0271
-rw-r--r--dev-libs/mpfr/files/2.4.2/patch0375
-rw-r--r--dev-libs/mpfr/files/3.0.0/patch01220
-rw-r--r--dev-libs/mpfr/files/3.0.0/patch02377
-rw-r--r--dev-libs/mpfr/files/3.0.0/patch0388
-rw-r--r--dev-libs/mpfr/files/3.0.1/patch01137
-rw-r--r--dev-libs/mpfr/files/3.0.1/patch0276
-rw-r--r--dev-libs/mpfr/files/3.0.1/patch03107
-rw-r--r--dev-libs/mpfr/files/3.0.1/patch0447
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch0150
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch0296
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch03247
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch04166
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch0569
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch0645
-rw-r--r--dev-libs/mpfr/files/3.1.0/patch07591
-rw-r--r--dev-libs/mpfr/files/3.1.1/patch01235
-rw-r--r--dev-libs/mpfr/files/3.1.1/patch02170
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch0145
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch02605
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch03129
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch0484
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch0542
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch0643
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch0771
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch08254
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch09166
-rw-r--r--dev-libs/mpfr/files/3.1.2/patch10138
-rw-r--r--dev-libs/mpfr/metadata.xml5
-rw-r--r--dev-libs/mpfr/mpfr-2.4.2_p3-r1.ebuild47
-rw-r--r--dev-libs/mpfr/mpfr-3.0.0_p3.ebuild59
-rw-r--r--dev-libs/mpfr/mpfr-3.0.1.ebuild59
-rw-r--r--dev-libs/mpfr/mpfr-3.0.1_p4-r1.ebuild64
-rw-r--r--dev-libs/mpfr/mpfr-3.0.1_p4.ebuild59
-rw-r--r--dev-libs/mpfr/mpfr-3.1.0.ebuild69
-rw-r--r--dev-libs/mpfr/mpfr-3.1.0_p7.ebuild69
-rw-r--r--dev-libs/mpfr/mpfr-3.1.1.ebuild69
-rw-r--r--dev-libs/mpfr/mpfr-3.1.1_p2.ebuild69
-rw-r--r--dev-libs/mpfr/mpfr-3.1.2-r1.ebuild73
-rw-r--r--dev-libs/mpfr/mpfr-3.1.2_p10.ebuild62
-rw-r--r--dev-libs/mpfr/mpfr-3.1.2_p5.ebuild73
-rw-r--r--dev-libs/mpfr/mpfr-3.1.3.ebuild62
44 files changed, 5474 insertions, 0 deletions
diff --git a/dev-libs/mpfr/Manifest b/dev-libs/mpfr/Manifest
new file mode 100644
index 000000000000..0f270a2d2568
--- /dev/null
+++ b/dev-libs/mpfr/Manifest
@@ -0,0 +1,7 @@
+DIST mpfr-2.4.2.tar.bz2 1077886 SHA256 c7e75a08a8d49d2082e4caee1591a05d11b9d5627514e678f02d66a124bcf2ba SHA512 c004b3dbf86c04960e4a1f8db37a409a7cc4cb76135e76e98dcc5ad93aaa8deb62334ee13ff84447a7c12a5e8cb57f25c62ac908c24920f1fb1a38d79d4a4c5e WHIRLPOOL d08935d1c5cda48753ddbf98b3b0e87d911279d7fea24e6b210da7e2378f769f3b20babe96859601195d6a9811cf8297d239df53ad2cfa6d0a1bb7bb02ac6a29
+DIST mpfr-3.0.0.tar.bz2 1138685 SHA256 8f4e5f9c53536cb798a30455ac429b1f9fc75a0f8af32d6e0ac31ebf1024821f SHA512 f404a5ebc48624406ff62ddc7c75c75ae06c207b0cdb60d330e95f2782fca9cf4875f8b8389b666bc96d4f157afbdf270d39d95ae890fc7f81027f744632d016 WHIRLPOOL 195eaafca24f4c11472eebc400899244966ed2f087604c8827314ca64ce4bb282af5ff683a1ffaeba5034d0ef82dbb627a88e77af7c1832b78b2ecb5a82d1b77
+DIST mpfr-3.0.1.tar.bz2 1154306 SHA256 e1977099bb494319c0f0c1f85759050c418a56884e9c6cef1c540b9b13e38e7f SHA512 bbac7d0d63fd3b4cd895e247c448adce7f4c2b6b66ecfe26af138018e0f96991fa8cbd8cbe94f924761aa1ac676e259af1228600dfc0854314e875e7739fd279 WHIRLPOOL 9d8e9fb6fd4c4526ae853e2bbf85c85dabe01000b0df6f79dcfdbb15f0df95f5a084f304e6e0bc78fbd768eecfb7749c5dfa03a772cc6444432dcaccb1c6adc9
+DIST mpfr-3.1.0.tar.bz2 1203891 SHA256 74a7bbbad168dd1cc414f1c9210b8fc16ccfc8e422d34b3371a8978e31eab680 SHA512 86083d8cf9dbcf1e33fcf1d73da8bd5b98fbc9187acf36b2d84c453fd18010aa659960a8026470e49d535d957f764941926a78acb31fe2869bf9a92524e0e81c WHIRLPOOL 7eb97b6df3ca8f903e2fa65c2f184edbf6cf990ce512eaf9598a52db381d74879e5549bf019e89b7d7d260d1347e19d6c03e8365e8340591e110d011090a7a4b
+DIST mpfr-3.1.1.tar.xz 1071688 SHA256 49d5acc32dbeec30a8e26af9c19845763d63feacb8bf97b12876008419f5a17a SHA512 4fcc87e19a08622b3211a33807e708b78da6c8659f391003703a9e170c485f56e6ebfff48d42afca7b4edb14fd9487684c4d8fd6c9f805ed62b6d5259d5721a8 WHIRLPOOL c4fdb3c7fba779cfa8900cd3b05322d4853bb6114ea42a5ec315d4489c25e962185f3e3cd3b3214360b55a58da02987c62c5ca92fb14989b38bd8c93bccd63d5
+DIST mpfr-3.1.2.tar.xz 1074388 SHA256 399d0f47ef6608cc01d29ed1b99c7faff36d9994c45f36f41ba250147100453b SHA512 8d594206afb2637ed39ad564d42c8c4d02b042b95925f5c6ec891e5cb87f7155195559c7ff477256a088ecaaa3c2b0d35a9d11a74ed526a1080d49b2950e5587 WHIRLPOOL 1e391888d9cecc71617e99eb841cafac536e703b12d46a53fdcf773cc2654c98ca6bde2358f997c8b7bfd832bdb0c395b224df8a460a8fb5b4ad6f2c2e092b17
+DIST mpfr-3.1.3.tar.xz 1112096 SHA256 6835a08bd992c8257641791e9a6a2b35b02336c8de26d0a8577953747e514a16 SHA512 79846fd82974269aa48152c2b6dbcb2321130dc4d0f0ba2eb94d56619b177add9b2077ebf88b4382c56db19c4215910e5a252f216715c1eee40baa299da42eb4 WHIRLPOOL fba9174551511ffa0fed80d906c5282c095697e79ab9b6fdeb915b9a81f15e20290b3ae6aa7c9ee9ef10fa9c0f973d8a75e1a169aae43f87a28ca433a93c57ce
diff --git a/dev-libs/mpfr/files/2.4.2/patch01 b/dev-libs/mpfr/files/2.4.2/patch01
new file mode 100644
index 000000000000..2721517c4281
--- /dev/null
+++ b/dev-libs/mpfr/files/2.4.2/patch01
@@ -0,0 +1,184 @@
+diff -Naurd mpfr-2.4.2-a/PATCHES mpfr-2.4.2-b/PATCHES
+--- mpfr-2.4.2-a/PATCHES 2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/PATCHES 2009-12-07 13:37:12.000000000 +0000
+@@ -0,0 +1 @@
++sin_cos_underflow
+diff -Naurd mpfr-2.4.2-a/VERSION mpfr-2.4.2-b/VERSION
+--- mpfr-2.4.2-a/VERSION 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/VERSION 2009-12-07 13:37:12.000000000 +0000
+@@ -1 +1 @@
+-2.4.2
++2.4.2-p1
+diff -Naurd mpfr-2.4.2-a/mpfr.h mpfr-2.4.2-b/mpfr.h
+--- mpfr-2.4.2-a/mpfr.h 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/mpfr.h 2009-12-07 13:37:12.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 2
+ #define MPFR_VERSION_MINOR 4
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "2.4.2"
++#define MPFR_VERSION_STRING "2.4.2-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-2.4.2-a/sin_cos.c mpfr-2.4.2-b/sin_cos.c
+--- mpfr-2.4.2-a/sin_cos.c 2009-11-30 02:43:09.000000000 +0000
++++ mpfr-2.4.2-b/sin_cos.c 2009-12-07 13:37:12.000000000 +0000
+@@ -82,17 +82,19 @@
+ if (y != x)
+ /* y and x differ, thus we can safely try to compute y first */
+ {
+- MPFR_FAST_COMPUTE_IF_SMALL_INPUT (y, x, -2 * expx, 2, 0, rnd_mode,
+- { inexy = _inexact;
+- goto small_input; });
++ MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++ y, x, -2 * expx, 2, 0, rnd_mode,
++ { inexy = _inexact;
++ goto small_input; });
+ if (0)
+ {
+ small_input:
+ /* we can go here only if we can round sin(x) */
+- MPFR_FAST_COMPUTE_IF_SMALL_INPUT (z, __gmpfr_one, -2 * expx,
+- 1, 0, rnd_mode,
+- { inexz = _inexact;
+- goto end; });
++ MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++ z, __gmpfr_one, -2 * expx, 1, 0, rnd_mode,
++ { inexz = _inexact;
++ MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
++ goto end; });
+ }
+
+ /* if we go here, one of the two MPFR_FAST_COMPUTE_IF_SMALL_INPUT
+@@ -101,18 +103,19 @@
+ else /* y and x are the same variable: try to compute z first, which
+ necessarily differs */
+ {
+- MPFR_FAST_COMPUTE_IF_SMALL_INPUT (z, __gmpfr_one, -2 * expx,
+- 1, 0, rnd_mode,
+- { inexz = _inexact;
+- goto small_input2; });
++ MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++ z, __gmpfr_one, -2 * expx, 1, 0, rnd_mode,
++ { inexz = _inexact;
++ goto small_input2; });
+ if (0)
+ {
+ small_input2:
+ /* we can go here only if we can round cos(x) */
+- MPFR_FAST_COMPUTE_IF_SMALL_INPUT (y, x, -2 * expx, 2, 0,
+- rnd_mode,
+- { inexy = _inexact;
+- goto end; });
++ MPFR_FAST_COMPUTE_IF_SMALL_INPUT (
++ y, x, -2 * expx, 2, 0, rnd_mode,
++ { inexy = _inexact;
++ MPFR_SAVE_EXPO_UPDATE_FLAGS (expo, __gmpfr_flags);
++ goto end; });
+ }
+ }
+ m += 2 * (-expx);
+@@ -207,7 +210,6 @@
+ mpfr_clear (xr);
+
+ end:
+- /* FIXME: update the underflow flag if need be. */
+ MPFR_SAVE_EXPO_FREE (expo);
+ mpfr_check_range (y, inexy, rnd_mode);
+ mpfr_check_range (z, inexz, rnd_mode);
+diff -Naurd mpfr-2.4.2-a/tests/tsin_cos.c mpfr-2.4.2-b/tests/tsin_cos.c
+--- mpfr-2.4.2-a/tests/tsin_cos.c 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/tests/tsin_cos.c 2009-12-07 13:37:12.000000000 +0000
+@@ -382,23 +382,56 @@
+ consistency (void)
+ {
+ mpfr_t x, s1, s2, c1, c2;
++ mp_exp_t emin, emax;
+ mp_rnd_t rnd;
++ unsigned int flags_sin, flags_cos, flags, flags_before, flags_ref;
++ int inex_sin, inex_cos, inex, inex_ref;
+ int i;
+
++ emin = mpfr_get_emin ();
++ emax = mpfr_get_emax ();
++
+ for (i = 0; i <= 10000; i++)
+ {
+ mpfr_init2 (x, MPFR_PREC_MIN + (randlimb () % 8));
+ mpfr_inits2 (MPFR_PREC_MIN + (randlimb () % 8), s1, s2, c1, c2,
+ (mpfr_ptr) 0);
+- tests_default_random (x, 256, -5, 50);
+- rnd = RND_RAND ();
+- mpfr_sin (s1, x, rnd);
+- mpfr_cos (c1, x, rnd);
+- mpfr_sin_cos (s2, c2, x, rnd);
+- if (!(mpfr_equal_p (s1, s2) && mpfr_equal_p (c1, c2)))
++ if (i < 8 * GMP_RND_MAX)
+ {
+- printf ("mpfr_sin_cos and mpfr_sin/mpfr_cos disagree on %s,\nx = ",
+- mpfr_print_rnd_mode (rnd));
++ int j = i / GMP_RND_MAX;
++ if (j & 1)
++ mpfr_set_emin (MPFR_EMIN_MIN);
++ mpfr_set_si (x, (j & 2) ? 1 : -1, GMP_RNDN);
++ mpfr_set_exp (x, mpfr_get_emin ());
++ rnd = (mpfr_rnd_t) (i % GMP_RND_MAX);
++ flags_before = 0;
++ if (j & 4)
++ mpfr_set_emax (-17);
++ }
++ else
++ {
++ tests_default_random (x, 256, -5, 50);
++ rnd = RND_RAND ();
++ flags_before = (randlimb () & 1) ?
++ (unsigned int) (MPFR_FLAGS_ALL ^ MPFR_FLAGS_ERANGE) :
++ (unsigned int) 0;
++ }
++ __gmpfr_flags = flags_before;
++ inex_sin = mpfr_sin (s1, x, rnd);
++ flags_sin = __gmpfr_flags;
++ __gmpfr_flags = flags_before;
++ inex_cos = mpfr_cos (c1, x, rnd);
++ flags_cos = __gmpfr_flags;
++ __gmpfr_flags = flags_before;
++ inex = !!mpfr_sin_cos (s2, c2, x, rnd);
++ flags = __gmpfr_flags;
++ inex_ref = inex_sin || inex_cos;
++ flags_ref = flags_sin | flags_cos;
++ if (!(mpfr_equal_p (s1, s2) && mpfr_equal_p (c1, c2)) ||
++ inex != inex_ref || flags != flags_ref)
++ {
++ printf ("mpfr_sin_cos and mpfr_sin/mpfr_cos disagree on %s,"
++ " i = %d\nx = ", mpfr_print_rnd_mode (rnd), i);
+ mpfr_dump (x);
+ printf ("s1 = ");
+ mpfr_dump (s1);
+@@ -408,9 +441,16 @@
+ mpfr_dump (c1);
+ printf ("c2 = ");
+ mpfr_dump (c2);
++ printf ("inex_sin = %d, inex_cos = %d, inex = %d (expected %d)\n",
++ inex_sin, inex_cos, inex, inex_ref);
++ printf ("flags_sin = 0x%x, flags_cos = 0x%x, "
++ "flags = 0x%x (expected 0x%x)\n",
++ flags_sin, flags_cos, flags, flags_ref);
+ exit (1);
+ }
+ mpfr_clears (x, s1, s2, c1, c2, (mpfr_ptr) 0);
++ mpfr_set_emin (emin);
++ mpfr_set_emax (emax);
+ }
+ }
+
+diff -Naurd mpfr-2.4.2-a/version.c mpfr-2.4.2-b/version.c
+--- mpfr-2.4.2-a/version.c 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/version.c 2009-12-07 13:37:12.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "2.4.2";
++ return "2.4.2-p1";
+ }
diff --git a/dev-libs/mpfr/files/2.4.2/patch02 b/dev-libs/mpfr/files/2.4.2/patch02
new file mode 100644
index 000000000000..fa85d8ef3c57
--- /dev/null
+++ b/dev-libs/mpfr/files/2.4.2/patch02
@@ -0,0 +1,71 @@
+diff -Naurd mpfr-2.4.2-a/PATCHES mpfr-2.4.2-b/PATCHES
+--- mpfr-2.4.2-a/PATCHES 2009-12-18 12:03:30.000000000 +0000
++++ mpfr-2.4.2-b/PATCHES 2009-12-18 12:05:19.000000000 +0000
+@@ -0,0 +1 @@
++longlong.h
+diff -Naurd mpfr-2.4.2-a/VERSION mpfr-2.4.2-b/VERSION
+--- mpfr-2.4.2-a/VERSION 2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/VERSION 2009-12-18 12:05:09.000000000 +0000
+@@ -1 +1 @@
+-2.4.2-p1
++2.4.2-p2
+diff -Naurd mpfr-2.4.2-a/mpfr-longlong.h mpfr-2.4.2-b/mpfr-longlong.h
+--- mpfr-2.4.2-a/mpfr-longlong.h 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/mpfr-longlong.h 2009-12-18 12:04:29.000000000 +0000
+@@ -1011,7 +1011,15 @@
+ #endif /* __m88000__ */
+
+ #if defined (__mips) && W_TYPE_SIZE == 32
+-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
++#if (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
++#define umul_ppmm(w1, w0, u, v) \
++ do { \
++ UDItype _r; \
++ _r = (UDItype) u * v; \
++ (w1) = _r >> 32; \
++ (w0) = (USItype) _r; \
++ } while (0)
++#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+ #define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("multu %2,%3" : "=l" (w0), "=h" (w1) : "d" (u), "d" (v))
+ #else
+@@ -1024,7 +1032,16 @@
+ #endif /* __mips */
+
+ #if (defined (__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+-#if __GNUC__ > 2 || __GNUC_MINOR__ >= 7
++#if (__GNUC__ >= 5) || (__GNUC__ >= 4 && __GNUC_MINOR__ >= 4)
++typedef unsigned int UTItype __attribute__ ((mode (TI)));
++#define umul_ppmm(w1, w0, u, v) \
++ do { \
++ UTItype _r; \
++ _r = (UTItype) u * v; \
++ (w1) = _r >> 64; \
++ (w0) = (UDItype) _r; \
++ } while (0)
++#elif __GNUC__ > 2 || __GNUC_MINOR__ >= 7
+ #define umul_ppmm(w1, w0, u, v) \
+ __asm__ ("dmultu %2,%3" : "=l" (w0), "=h" (w1) : "d" (u), "d" (v))
+ #else
+diff -Naurd mpfr-2.4.2-a/mpfr.h mpfr-2.4.2-b/mpfr.h
+--- mpfr-2.4.2-a/mpfr.h 2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/mpfr.h 2009-12-18 12:05:09.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 2
+ #define MPFR_VERSION_MINOR 4
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "2.4.2-p1"
++#define MPFR_VERSION_STRING "2.4.2-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-2.4.2-a/version.c mpfr-2.4.2-b/version.c
+--- mpfr-2.4.2-a/version.c 2009-12-07 13:37:12.000000000 +0000
++++ mpfr-2.4.2-b/version.c 2009-12-18 12:05:09.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "2.4.2-p1";
++ return "2.4.2-p2";
+ }
diff --git a/dev-libs/mpfr/files/2.4.2/patch03 b/dev-libs/mpfr/files/2.4.2/patch03
new file mode 100644
index 000000000000..3ce4952f2f38
--- /dev/null
+++ b/dev-libs/mpfr/files/2.4.2/patch03
@@ -0,0 +1,75 @@
+diff -Naurd mpfr-2.4.2-a/PATCHES mpfr-2.4.2-b/PATCHES
+--- mpfr-2.4.2-a/PATCHES 2010-01-11 15:27:18.000000000 +0000
++++ mpfr-2.4.2-b/PATCHES 2010-01-11 15:30:31.000000000 +0000
+@@ -0,0 +1 @@
++gmp5
+diff -Naurd mpfr-2.4.2-a/VERSION mpfr-2.4.2-b/VERSION
+--- mpfr-2.4.2-a/VERSION 2009-12-18 12:05:09.000000000 +0000
++++ mpfr-2.4.2-b/VERSION 2010-01-11 15:29:40.000000000 +0000
+@@ -1 +1 @@
+-2.4.2-p2
++2.4.2-p3
+diff -Naurd mpfr-2.4.2-a/configure mpfr-2.4.2-b/configure
+--- mpfr-2.4.2-a/configure 2009-11-30 02:44:35.000000000 +0000
++++ mpfr-2.4.2-b/configure 2010-01-11 15:28:56.000000000 +0000
+@@ -20449,6 +20449,9 @@
+ main ()
+ {
+
++#ifndef BITS_PER_MP_LIMB
++#define BITS_PER_MP_LIMB GMP_LIMB_BITS
++#endif
+ return BITS_PER_MP_LIMB == BYTES_PER_MP_LIMB * CHAR_BIT
+ && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
+
+diff -Naurd mpfr-2.4.2-a/configure.in mpfr-2.4.2-b/configure.in
+--- mpfr-2.4.2-a/configure.in 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/configure.in 2009-11-30 02:43:08.000000000 +0000
+@@ -424,6 +424,9 @@
+ #include "gmp.h"
+ #include "gmp-impl.h"
+ ]], [[
++#ifndef BITS_PER_MP_LIMB
++#define BITS_PER_MP_LIMB GMP_LIMB_BITS
++#endif
+ return BITS_PER_MP_LIMB == BYTES_PER_MP_LIMB * CHAR_BIT
+ && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
+ ]])], [AC_MSG_RESULT(yes)], [
+diff -Naurd mpfr-2.4.2-a/mpfr-impl.h mpfr-2.4.2-b/mpfr-impl.h
+--- mpfr-2.4.2-a/mpfr-impl.h 2009-11-30 02:43:08.000000000 +0000
++++ mpfr-2.4.2-b/mpfr-impl.h 2010-01-11 15:28:01.000000000 +0000
+@@ -65,6 +65,12 @@
+ # ifndef __GMP_IMPL_H__
+ # include "gmp-impl.h"
+ # endif
++# ifndef BITS_PER_MP_LIMB
++# define BITS_PER_MP_LIMB GMP_LIMB_BITS
++# endif
++#ifndef mpn_sqr_n
++# define mpn_sqr_n mpn_sqr
++#endif
+ # ifdef MPFR_NEED_LONGLONG_H
+ # include "longlong.h"
+ # endif
+diff -Naurd mpfr-2.4.2-a/mpfr.h mpfr-2.4.2-b/mpfr.h
+--- mpfr-2.4.2-a/mpfr.h 2009-12-18 12:05:09.000000000 +0000
++++ mpfr-2.4.2-b/mpfr.h 2010-01-11 15:29:40.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 2
+ #define MPFR_VERSION_MINOR 4
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "2.4.2-p2"
++#define MPFR_VERSION_STRING "2.4.2-p3"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-2.4.2-a/version.c mpfr-2.4.2-b/version.c
+--- mpfr-2.4.2-a/version.c 2009-12-18 12:05:09.000000000 +0000
++++ mpfr-2.4.2-b/version.c 2010-01-11 15:29:40.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "2.4.2-p2";
++ return "2.4.2-p3";
+ }
diff --git a/dev-libs/mpfr/files/3.0.0/patch01 b/dev-libs/mpfr/files/3.0.0/patch01
new file mode 100644
index 000000000000..da98aab758f9
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.0/patch01
@@ -0,0 +1,220 @@
+diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
+--- mpfr-3.0.0-a/PATCHES 2010-06-23 11:02:49.000000000 +0000
++++ mpfr-3.0.0-b/PATCHES 2010-06-23 11:03:36.000000000 +0000
+@@ -0,0 +1 @@
++mpfr_out_str
+diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
+--- mpfr-3.0.0-a/VERSION 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/VERSION 2010-06-23 11:03:20.000000000 +0000
+@@ -1 +1 @@
+-3.0.0
++3.0.0-p1
+diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
+--- mpfr-3.0.0-a/mpfr.h 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/mpfr.h 2010-06-23 11:03:20.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.0.0"
++#define MPFR_VERSION_STRING "3.0.0-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.0-a/mpfr.texi mpfr-3.0.0-b/mpfr.texi
+--- mpfr-3.0.0-a/mpfr.texi 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/mpfr.texi 2010-06-23 11:03:12.000000000 +0000
+@@ -2050,7 +2050,7 @@
+ are printed. If @var{base} is greater than 10, @samp{@@} will be used
+ instead of @samp{e} as exponent delimiter.
+
+-Return the number of bytes written, or if an error occurred, return 0.
++Return the number of characters written, or if an error occurred, return 0.
+ @end deftypefun
+
+ @deftypefun size_t mpfr_inp_str (mpfr_t @var{rop}, FILE *@var{stream}, int @var{base}, mpfr_rnd_t @var{rnd})
+diff -Naurd mpfr-3.0.0-a/out_str.c mpfr-3.0.0-b/out_str.c
+--- mpfr-3.0.0-a/out_str.c 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/out_str.c 2010-06-23 11:03:12.000000000 +0000
+@@ -22,6 +22,16 @@
+
+ #include "mpfr-impl.h"
+
++/* Warning! S should not contain "%". */
++#define OUT_STR_RET(S) \
++ do \
++ { \
++ int r; \
++ r = fprintf (stream, (S)); \
++ return r < 0 ? 0 : r; \
++ } \
++ while (0)
++
+ size_t
+ mpfr_out_str (FILE *stream, int base, size_t n_digits, mpfr_srcptr op,
+ mpfr_rnd_t rnd_mode)
+@@ -29,6 +39,7 @@
+ char *s, *s0;
+ size_t l;
+ mpfr_exp_t e;
++ int err;
+
+ MPFR_ASSERTN (base >= 2 && base <= 62);
+
+@@ -36,37 +47,16 @@
+ if (stream == NULL)
+ stream = stdout;
+
+- if (MPFR_IS_NAN(op))
+- {
+- fprintf (stream, "@NaN@");
+- return 3;
+- }
+-
+- if (MPFR_IS_INF(op))
+- {
+- if (MPFR_SIGN(op) > 0)
+- {
+- fprintf (stream, "@Inf@");
+- return 3;
+- }
+- else
+- {
+- fprintf (stream, "-@Inf@");
+- return 4;
+- }
+- }
+-
+- if (MPFR_IS_ZERO(op))
++ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (op)))
+ {
+- if (MPFR_SIGN(op) > 0)
+- {
+- fprintf(stream, "0");
+- return 1;
+- }
++ if (MPFR_IS_NAN (op))
++ OUT_STR_RET ("@NaN@");
++ else if (MPFR_IS_INF (op))
++ OUT_STR_RET (MPFR_IS_POS (op) ? "@Inf@" : "-@Inf@");
+ else
+ {
+- fprintf(stream, "-0");
+- return 2;
++ MPFR_ASSERTD (MPFR_IS_ZERO (op));
++ OUT_STR_RET (MPFR_IS_POS (op) ? "0" : "-0");
+ }
+ }
+
+@@ -77,21 +67,31 @@
+
+ l = strlen (s) + 1; /* size of allocated block returned by mpfr_get_str
+ - may be incorrect, as only an upper bound? */
+- if (*s == '-')
+- fputc (*s++, stream);
+
+- /* outputs mantissa */
+- fputc (*s++, stream); e--; /* leading digit */
+- fputc ((unsigned char) MPFR_DECIMAL_POINT, stream);
+- fputs (s, stream); /* rest of mantissa */
++ /* outputs possible sign and significand */
++ err = (*s == '-' && fputc (*s++, stream) == EOF)
++ || fputc (*s++, stream) == EOF /* leading digit */
++ || fputc ((unsigned char) MPFR_DECIMAL_POINT, stream) == EOF
++ || fputs (s, stream) == EOF; /* trailing significand */
+ (*__gmp_free_func) (s0, l);
++ if (MPFR_UNLIKELY (err))
++ return 0;
++
++ e--; /* due to the leading digit */
+
+ /* outputs exponent */
+ if (e)
+ {
++ int r;
++
+ MPFR_ASSERTN(e >= LONG_MIN);
+ MPFR_ASSERTN(e <= LONG_MAX);
+- l += fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
++
++ r = fprintf (stream, (base <= 10 ? "e%ld" : "@%ld"), (long) e);
++ if (MPFR_UNLIKELY (r < 0))
++ return 0;
++
++ l += r;
+ }
+
+ return l;
+diff -Naurd mpfr-3.0.0-a/tests/tout_str.c mpfr-3.0.0-b/tests/tout_str.c
+--- mpfr-3.0.0-a/tests/tout_str.c 2010-06-10 11:00:13.000000000 +0000
++++ mpfr-3.0.0-b/tests/tout_str.c 2010-06-23 11:03:12.000000000 +0000
+@@ -46,22 +46,54 @@
+ special (void)
+ {
+ mpfr_t x;
++ unsigned int n;
+
+ mpfr_init (x);
+
+ mpfr_set_nan (x);
+- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ if (n != 5)
++ {
++ printf ("Error: mpfr_out_str (file, 10, 0, NaN, MPFR_RNDN) wrote %u "
++ "characters instead of 5.\n", n);
++ exit (1);
++ }
+
+ mpfr_set_inf (x, 1);
+- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ if (n != 5)
++ {
++ printf ("Error: mpfr_out_str (file, 10, 0, +Inf, MPFR_RNDN) wrote %u "
++ "characters instead of 5.\n", n);
++ exit (1);
++ }
+
+ mpfr_set_inf (x, -1);
+- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ if (n != 6)
++ {
++ printf ("Error: mpfr_out_str (file, 10, 0, -Inf, MPFR_RNDN) wrote %u "
++ "characters instead of 6.\n", n);
++ exit (1);
++ }
+
+ mpfr_set_ui (x, 0, MPFR_RNDN);
+- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ if (n != 1)
++ {
++ printf ("Error: mpfr_out_str (file, 10, 0, +0, MPFR_RNDN) wrote %u "
++ "characters instead of 1.\n", n);
++ exit (1);
++ }
++
+ mpfr_neg (x, x, MPFR_RNDN);
+- mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ n = mpfr_out_str (fout, 10, 0, x, MPFR_RNDN);
++ if (n != 2)
++ {
++ printf ("Error: mpfr_out_str (file, 10, 0, -0, MPFR_RNDN) wrote %u "
++ "characters instead of 2.\n", n);
++ exit (1);
++ }
+
+ mpfr_clear (x);
+ }
+diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
+--- mpfr-3.0.0-a/version.c 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/version.c 2010-06-23 11:03:20.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.0";
++ return "3.0.0-p1";
+ }
diff --git a/dev-libs/mpfr/files/3.0.0/patch02 b/dev-libs/mpfr/files/3.0.0/patch02
new file mode 100644
index 000000000000..af6dfb21380f
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.0/patch02
@@ -0,0 +1,377 @@
+diff -Naurd mpfr-3.0.0-a/Makefile.in mpfr-3.0.0-b/Makefile.in
+--- mpfr-3.0.0-a/Makefile.in 2010-06-10 11:00:52.000000000 +0000
++++ mpfr-3.0.0-b/Makefile.in 2010-06-10 11:00:52.000000000 +0000
+@@ -239,6 +239,7 @@
+ distuninstallcheck_listfiles = find . -type f -print
+ distcleancheck_listfiles = find . -type f -print
+ ACLOCAL = @ACLOCAL@
++ALLOCA = @ALLOCA@
+ AMTAR = @AMTAR@
+ AR = @AR@
+ AS = @AS@
+diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
+--- mpfr-3.0.0-a/PATCHES 2010-06-23 11:03:36.000000000 +0000
++++ mpfr-3.0.0-b/PATCHES 2010-06-25 13:23:13.000000000 +0000
+@@ -0,0 +1 @@
++alloca
+diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
+--- mpfr-3.0.0-a/VERSION 2010-06-23 11:03:20.000000000 +0000
++++ mpfr-3.0.0-b/VERSION 2010-06-25 13:23:13.000000000 +0000
+@@ -1 +1 @@
+-3.0.0-p1
++3.0.0-p2
+diff -Naurd mpfr-3.0.0-a/acinclude.m4 mpfr-3.0.0-b/acinclude.m4
+--- mpfr-3.0.0-a/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/acinclude.m4 2010-06-10 11:00:14.000000000 +0000
+@@ -59,6 +59,9 @@
+ dnl sys/fpu.h - MIPS specific
+ AC_CHECK_HEADERS([sys/time.h sys/fpu.h])
+
++dnl Check how to get `alloca'
++AC_FUNC_ALLOCA
++
+ dnl SIZE_MAX macro
+ gl_SIZE_MAX
+
+diff -Naurd mpfr-3.0.0-a/configure mpfr-3.0.0-b/configure
+--- mpfr-3.0.0-a/configure 2010-06-10 11:00:51.000000000 +0000
++++ mpfr-3.0.0-b/configure 2010-06-25 13:23:05.000000000 +0000
+@@ -783,6 +783,7 @@
+ OBJDUMP
+ DLLTOOL
+ AS
++ALLOCA
+ MPFR_LIBM
+ ANSI2KNR
+ U
+@@ -5622,6 +5623,197 @@
+ done
+
+
++# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
++# for constant arguments. Useless!
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working alloca.h" >&5
++$as_echo_n "checking for working alloca.h... " >&6; }
++if test "${ac_cv_working_alloca_h+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#include <alloca.h>
++int
++main ()
++{
++char *p = (char *) alloca (2 * sizeof (int));
++ if (p) return 0;
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_working_alloca_h=yes
++else
++ ac_cv_working_alloca_h=no
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_working_alloca_h" >&5
++$as_echo "$ac_cv_working_alloca_h" >&6; }
++if test $ac_cv_working_alloca_h = yes; then
++
++$as_echo "#define HAVE_ALLOCA_H 1" >>confdefs.h
++
++fi
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for alloca" >&5
++$as_echo_n "checking for alloca... " >&6; }
++if test "${ac_cv_func_alloca_works+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#ifdef __GNUC__
++# define alloca __builtin_alloca
++#else
++# ifdef _MSC_VER
++# include <malloc.h>
++# define alloca _alloca
++# else
++# ifdef HAVE_ALLOCA_H
++# include <alloca.h>
++# else
++# ifdef _AIX
++ #pragma alloca
++# else
++# ifndef alloca /* predefined by HP cc +Olibcalls */
++char *alloca ();
++# endif
++# endif
++# endif
++# endif
++#endif
++
++int
++main ()
++{
++char *p = (char *) alloca (1);
++ if (p) return 0;
++ ;
++ return 0;
++}
++_ACEOF
++if ac_fn_c_try_link "$LINENO"; then :
++ ac_cv_func_alloca_works=yes
++else
++ ac_cv_func_alloca_works=no
++fi
++rm -f core conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_alloca_works" >&5
++$as_echo "$ac_cv_func_alloca_works" >&6; }
++
++if test $ac_cv_func_alloca_works = yes; then
++
++$as_echo "#define HAVE_ALLOCA 1" >>confdefs.h
++
++else
++ # The SVR3 libPW and SVR4 libucb both contain incompatible functions
++# that cause trouble. Some versions do not even contain alloca or
++# contain a buggy version. If you still want to use their alloca,
++# use ar to extract alloca.o from them instead of compiling alloca.c.
++
++ALLOCA=\${LIBOBJDIR}alloca.$ac_objext
++
++$as_echo "#define C_ALLOCA 1" >>confdefs.h
++
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether \`alloca.c' needs Cray hooks" >&5
++$as_echo_n "checking whether \`alloca.c' needs Cray hooks... " >&6; }
++if test "${ac_cv_os_cray+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++#if defined CRAY && ! defined CRAY2
++webecray
++#else
++wenotbecray
++#endif
++
++_ACEOF
++if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
++ $EGREP "webecray" >/dev/null 2>&1; then :
++ ac_cv_os_cray=yes
++else
++ ac_cv_os_cray=no
++fi
++rm -f conftest*
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cray" >&5
++$as_echo "$ac_cv_os_cray" >&6; }
++if test $ac_cv_os_cray = yes; then
++ for ac_func in _getb67 GETB67 getb67; do
++ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
++ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
++eval as_val=\$$as_ac_var
++ if test "x$as_val" = x""yes; then :
++
++cat >>confdefs.h <<_ACEOF
++#define CRAY_STACKSEG_END $ac_func
++_ACEOF
++
++ break
++fi
++
++ done
++fi
++
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking stack direction for C alloca" >&5
++$as_echo_n "checking stack direction for C alloca... " >&6; }
++if test "${ac_cv_c_stack_direction+set}" = set; then :
++ $as_echo_n "(cached) " >&6
++else
++ if test "$cross_compiling" = yes; then :
++ ac_cv_c_stack_direction=0
++else
++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
++/* end confdefs.h. */
++$ac_includes_default
++int
++find_stack_direction ()
++{
++ static char *addr = 0;
++ auto char dummy;
++ if (addr == 0)
++ {
++ addr = &dummy;
++ return find_stack_direction ();
++ }
++ else
++ return (&dummy > addr) ? 1 : -1;
++}
++
++int
++main ()
++{
++ return find_stack_direction () < 0;
++}
++_ACEOF
++if ac_fn_c_try_run "$LINENO"; then :
++ ac_cv_c_stack_direction=1
++else
++ ac_cv_c_stack_direction=-1
++fi
++rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
++ conftest.$ac_objext conftest.beam conftest.$ac_ext
++fi
++
++fi
++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_stack_direction" >&5
++$as_echo "$ac_cv_c_stack_direction" >&6; }
++cat >>confdefs.h <<_ACEOF
++#define STACK_DIRECTION $ac_cv_c_stack_direction
++_ACEOF
++
++
++fi
++
++
+
+ for ac_header in stdint.h
+ do :
+@@ -7564,13 +7756,13 @@
+ else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+- (eval echo "\"\$as_me:7567: $ac_compile\"" >&5)
++ (eval echo "\"\$as_me:7759: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+- (eval echo "\"\$as_me:7570: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
++ (eval echo "\"\$as_me:7762: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+- (eval echo "\"\$as_me:7573: output\"" >&5)
++ (eval echo "\"\$as_me:7765: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+@@ -8772,7 +8964,7 @@
+ ;;
+ *-*-irix6*)
+ # Find out which ABI we are using.
+- echo '#line 8775 "configure"' > conftest.$ac_ext
++ echo '#line 8967 "configure"' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+@@ -10032,11 +10224,11 @@
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10035: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10227: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+- echo "$as_me:10039: \$? = $ac_status" >&5
++ echo "$as_me:10231: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+@@ -10371,11 +10563,11 @@
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10374: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10566: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+- echo "$as_me:10378: \$? = $ac_status" >&5
++ echo "$as_me:10570: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s "$ac_outfile"; then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings other than the usual output.
+@@ -10476,11 +10668,11 @@
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10479: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10671: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:10483: \$? = $ac_status" >&5
++ echo "$as_me:10675: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -10531,11 +10723,11 @@
+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+ -e 's:$: $lt_compiler_flag:'`
+- (eval echo "\"\$as_me:10534: $lt_compile\"" >&5)
++ (eval echo "\"\$as_me:10726: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+- echo "$as_me:10538: \$? = $ac_status" >&5
++ echo "$as_me:10730: \$? = $ac_status" >&5
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+@@ -12915,7 +13107,7 @@
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 12918 "configure"
++#line 13110 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+@@ -13011,7 +13203,7 @@
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+-#line 13014 "configure"
++#line 13206 "configure"
+ #include "confdefs.h"
+
+ #if HAVE_DLFCN_H
+diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
+--- mpfr-3.0.0-a/mpfr.h 2010-06-23 11:03:20.000000000 +0000
++++ mpfr-3.0.0-b/mpfr.h 2010-06-25 13:23:13.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.0.0-p1"
++#define MPFR_VERSION_STRING "3.0.0-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.0-a/tests/Makefile.in mpfr-3.0.0-b/tests/Makefile.in
+--- mpfr-3.0.0-a/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
++++ mpfr-3.0.0-b/tests/Makefile.in 2010-06-10 11:00:52.000000000 +0000
+@@ -960,6 +960,7 @@
+ red=; grn=; lgn=; blu=; std=
+ DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ ACLOCAL = @ACLOCAL@
++ALLOCA = @ALLOCA@
+ AMTAR = @AMTAR@
+ AR = @AR@
+ AS = @AS@
+diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
+--- mpfr-3.0.0-a/version.c 2010-06-23 11:03:20.000000000 +0000
++++ mpfr-3.0.0-b/version.c 2010-06-25 13:23:13.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.0-p1";
++ return "3.0.0-p2";
+ }
diff --git a/dev-libs/mpfr/files/3.0.0/patch03 b/dev-libs/mpfr/files/3.0.0/patch03
new file mode 100644
index 000000000000..cf8a936ec62f
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.0/patch03
@@ -0,0 +1,88 @@
+diff -Naurd mpfr-3.0.0-a/PATCHES mpfr-3.0.0-b/PATCHES
+--- mpfr-3.0.0-a/PATCHES 2010-07-10 00:11:19.000000000 +0000
++++ mpfr-3.0.0-b/PATCHES 2010-07-10 00:12:50.000000000 +0000
+@@ -0,0 +1 @@
++gamma_underflow
+diff -Naurd mpfr-3.0.0-a/VERSION mpfr-3.0.0-b/VERSION
+--- mpfr-3.0.0-a/VERSION 2010-06-25 13:23:13.000000000 +0000
++++ mpfr-3.0.0-b/VERSION 2010-07-10 00:11:53.000000000 +0000
+@@ -1 +1 @@
+-3.0.0-p2
++3.0.0-p3
+diff -Naurd mpfr-3.0.0-a/gamma.c mpfr-3.0.0-b/gamma.c
+--- mpfr-3.0.0-a/gamma.c 2010-06-10 11:00:14.000000000 +0000
++++ mpfr-3.0.0-b/gamma.c 2010-07-10 00:11:46.000000000 +0000
+@@ -274,7 +274,7 @@
+ /* we want an upper bound for x * [log(2-x)-1].
+ since x < 0, we need a lower bound on log(2-x) */
+ mpfr_ui_sub (xp, 2, x, MPFR_RNDD);
+- mpfr_log (xp, xp, MPFR_RNDD);
++ mpfr_log2 (xp, xp, MPFR_RNDD);
+ mpfr_sub_ui (xp, xp, 1, MPFR_RNDD);
+ mpfr_mul (xp, xp, x, MPFR_RNDU);
+
+@@ -303,8 +303,8 @@
+ {
+ mpfr_sub (tmp, tmp, tmp2, MPFR_RNDZ); /* low bnd on |sin(Pi*(2-x))| */
+ mpfr_ui_div (tmp, 12, tmp, MPFR_RNDU); /* upper bound */
+- mpfr_log (tmp, tmp, MPFR_RNDU);
+- mpfr_add (tmp, tmp, xp, MPFR_RNDU);
++ mpfr_log2 (tmp, tmp, MPFR_RNDU);
++ mpfr_add (xp, tmp, xp, MPFR_RNDU);
+ underflow = mpfr_cmp_si (xp, expo.saved_emin - 2) <= 0;
+ }
+
+diff -Naurd mpfr-3.0.0-a/mpfr.h mpfr-3.0.0-b/mpfr.h
+--- mpfr-3.0.0-a/mpfr.h 2010-06-25 13:23:13.000000000 +0000
++++ mpfr-3.0.0-b/mpfr.h 2010-07-10 00:11:53.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.0.0-p2"
++#define MPFR_VERSION_STRING "3.0.0-p3"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.0-a/tests/tgamma.c mpfr-3.0.0-b/tests/tgamma.c
+--- mpfr-3.0.0-a/tests/tgamma.c 2010-06-10 11:00:13.000000000 +0000
++++ mpfr-3.0.0-b/tests/tgamma.c 2010-07-10 00:11:46.000000000 +0000
+@@ -461,6 +461,20 @@
+ mpfr_clear (x);
+ }
+
++/* bug found by Stathis, only occurs on 32-bit machines */
++static void
++test20100709 (void)
++{
++ mpfr_t x;
++ int inex;
++
++ mpfr_init2 (x, 100);
++ mpfr_set_str (x, "-4.6308260837372266e+07", 10, MPFR_RNDN);
++ inex = mpfr_gamma (x, x, MPFR_RNDN);
++ MPFR_ASSERTN(MPFR_IS_ZERO(x) && MPFR_IS_NEG(x) && inex > 0);
++ mpfr_clear (x);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -471,6 +485,7 @@
+ test_generic (2, 100, 2);
+ gamma_integer ();
+ test20071231 ();
++ test20100709 ();
+
+ data_check ("data/gamma", mpfr_gamma, "mpfr_gamma");
+
+diff -Naurd mpfr-3.0.0-a/version.c mpfr-3.0.0-b/version.c
+--- mpfr-3.0.0-a/version.c 2010-06-25 13:23:13.000000000 +0000
++++ mpfr-3.0.0-b/version.c 2010-07-10 00:11:53.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.0-p2";
++ return "3.0.0-p3";
+ }
diff --git a/dev-libs/mpfr/files/3.0.1/patch01 b/dev-libs/mpfr/files/3.0.1/patch01
new file mode 100644
index 000000000000..d79a6f9f2465
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.1/patch01
@@ -0,0 +1,137 @@
+diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
+--- mpfr-3.0.1-a/PATCHES 2011-04-12 10:50:02.000000000 +0000
++++ mpfr-3.0.1-b/PATCHES 2011-04-12 10:50:02.000000000 +0000
+@@ -0,0 +1 @@
++asin_exprange
+diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
+--- mpfr-3.0.1-a/VERSION 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/VERSION 2011-04-12 10:50:02.000000000 +0000
+@@ -1 +1 @@
+-3.0.1
++3.0.1-p1
+diff -Naurd mpfr-3.0.1-a/asin.c mpfr-3.0.1-b/asin.c
+--- mpfr-3.0.1-a/asin.c 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/asin.c 2011-04-12 10:50:02.000000000 +0000
+@@ -63,11 +63,14 @@
+
+ compared = mpfr_cmp_ui (xp, 1);
+
++ MPFR_SAVE_EXPO_MARK (expo);
++
+ if (MPFR_UNLIKELY (compared >= 0))
+ {
+ mpfr_clear (xp);
+ if (compared > 0) /* asin(x) = NaN for |x| > 1 */
+ {
++ MPFR_SAVE_EXPO_FREE (expo);
+ MPFR_SET_NAN (asin);
+ MPFR_RET_NAN;
+ }
+@@ -80,13 +83,11 @@
+ inexact = -mpfr_const_pi (asin, MPFR_INVERT_RND(rnd_mode));
+ MPFR_CHANGE_SIGN (asin);
+ }
+- mpfr_div_2ui (asin, asin, 1, rnd_mode); /* May underflow */
+- return inexact;
++ mpfr_div_2ui (asin, asin, 1, rnd_mode);
+ }
+ }
+-
+- MPFR_SAVE_EXPO_MARK (expo);
+-
++ else
++ {
+ /* Compute exponent of 1 - ABS(x) */
+ mpfr_ui_sub (xp, 1, xp, MPFR_RNDD);
+ MPFR_ASSERTD (MPFR_GET_EXP (xp) <= 0);
+@@ -115,6 +116,7 @@
+ inexact = mpfr_set (asin, xp, rnd_mode);
+
+ mpfr_clear (xp);
++ }
+
+ MPFR_SAVE_EXPO_FREE (expo);
+ return mpfr_check_range (asin, inexact, rnd_mode);
+diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
+--- mpfr-3.0.1-a/mpfr.h 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/mpfr.h 2011-04-12 10:50:02.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.0.1"
++#define MPFR_VERSION_STRING "3.0.1-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.1-a/tests/tasin.c mpfr-3.0.1-b/tests/tasin.c
+--- mpfr-3.0.1-a/tests/tasin.c 2011-04-04 10:19:17.000000000 +0000
++++ mpfr-3.0.1-b/tests/tasin.c 2011-04-12 10:50:02.000000000 +0000
+@@ -219,6 +219,49 @@
+ mpfr_clear (y);
+ }
+
++static void
++reduced_expo_range (void)
++{
++ mpfr_exp_t emin, emax;
++ mpfr_t x, y, ex_y;
++ int inex, ex_inex;
++ unsigned int flags, ex_flags;
++
++ emin = mpfr_get_emin ();
++ emax = mpfr_get_emax ();
++
++ mpfr_inits2 (4, x, y, ex_y, (mpfr_ptr) 0);
++ mpfr_set_str (x, "-0.1e1", 2, MPFR_RNDN);
++
++ mpfr_set_emin (1);
++ mpfr_set_emax (1);
++ mpfr_clear_flags ();
++ inex = mpfr_asin (y, x, MPFR_RNDA);
++ flags = __gmpfr_flags;
++ mpfr_set_emin (emin);
++ mpfr_set_emax (emax);
++
++ mpfr_set_str (ex_y, "-0.1101e1", 2, MPFR_RNDN);
++ ex_inex = -1;
++ ex_flags = MPFR_FLAGS_INEXACT;
++
++ if (SIGN (inex) != ex_inex || flags != ex_flags ||
++ ! mpfr_equal_p (y, ex_y))
++ {
++ printf ("Error in reduced_expo_range\non x = ");
++ mpfr_dump (x);
++ printf ("Expected y = ");
++ mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
++ printf ("\n inex = %d, flags = %u\n", ex_inex, ex_flags);
++ printf ("Got y = ");
++ mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
++ printf ("\n inex = %d, flags = %u\n", SIGN (inex), flags);
++ exit (1);
++ }
++
++ mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
++}
++
+ int
+ main (void)
+ {
+@@ -226,6 +269,7 @@
+
+ special ();
+ special_overflow ();
++ reduced_expo_range ();
+
+ test_generic (2, 100, 15);
+
+diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
+--- mpfr-3.0.1-a/version.c 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/version.c 2011-04-12 10:50:02.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.1";
++ return "3.0.1-p1";
+ }
diff --git a/dev-libs/mpfr/files/3.0.1/patch02 b/dev-libs/mpfr/files/3.0.1/patch02
new file mode 100644
index 000000000000..0367d846a060
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.1/patch02
@@ -0,0 +1,76 @@
+diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
+--- mpfr-3.0.1-a/PATCHES 2011-05-04 11:18:33.000000000 +0000
++++ mpfr-3.0.1-b/PATCHES 2011-05-04 11:18:33.000000000 +0000
+@@ -0,0 +1 @@
++rec_sqrt-carry
+diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
+--- mpfr-3.0.1-a/VERSION 2011-04-12 10:50:02.000000000 +0000
++++ mpfr-3.0.1-b/VERSION 2011-05-04 11:18:33.000000000 +0000
+@@ -1 +1 @@
+-3.0.1-p1
++3.0.1-p2
+diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
+--- mpfr-3.0.1-a/mpfr.h 2011-04-12 10:50:02.000000000 +0000
++++ mpfr-3.0.1-b/mpfr.h 2011-05-04 11:18:33.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.0.1-p1"
++#define MPFR_VERSION_STRING "3.0.1-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.1-a/rec_sqrt.c mpfr-3.0.1-b/rec_sqrt.c
+--- mpfr-3.0.1-a/rec_sqrt.c 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/rec_sqrt.c 2011-05-04 11:18:33.000000000 +0000
+@@ -375,20 +375,37 @@
+ MPFR_ASSERTD(un == ln + 1 || un == ln + 2);
+ /* the high un-ln limbs of u will overlap the low part of {x+ln,xn},
+ we need to add or subtract the overlapping part {u + ln, un - ln} */
++ /* Warning! th may be 0, in which case the mpn_add_1 and mpn_sub_1
++ below (with size = th) mustn't be used. In such a case, the limb
++ (carry) will be 0, so that this is semantically a no-op, but if
++ mpn_add_1 and mpn_sub_1 are used, GMP (currently) still does a
++ non-atomic read/write in a place that is not always allocated,
++ with the possible consequences: a crash if the corresponding
++ address is not mapped, or (rather unlikely) memory corruption
++ if another process/thread writes at the same place; things may
++ be worse with future GMP versions. Hence the tests carry != 0. */
+ if (neg == 0)
+ {
+ if (ln > 0)
+ MPN_COPY (x, u, ln);
+ cy = mpn_add (x + ln, x + ln, xn, u + ln, un - ln);
+ /* add cu at x+un */
+- cy += mpn_add_1 (x + un, x + un, th, cu);
++ if (cu != 0)
++ {
++ MPFR_ASSERTD (th != 0);
++ cy += mpn_add_1 (x + un, x + un, th, cu);
++ }
+ }
+ else /* negative case */
+ {
+ /* subtract {u+ln, un-ln} from {x+ln,un} */
+ cy = mpn_sub (x + ln, x + ln, xn, u + ln, un - ln);
+ /* carry cy is at x+un, like cu */
+- cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
++ if (cy + cu != 0)
++ {
++ MPFR_ASSERTD (th != 0);
++ cy = mpn_sub_1 (x + un, x + un, th, cy + cu); /* n - un = th */
++ }
+ /* cy cannot be zero, since the most significant bit of Xh is 1,
+ and the correction is bounded by 2^{-h+3} */
+ MPFR_ASSERTD(cy == 0);
+diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
+--- mpfr-3.0.1-a/version.c 2011-04-12 10:50:02.000000000 +0000
++++ mpfr-3.0.1-b/version.c 2011-05-04 11:18:33.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.1-p1";
++ return "3.0.1-p2";
+ }
diff --git a/dev-libs/mpfr/files/3.0.1/patch03 b/dev-libs/mpfr/files/3.0.1/patch03
new file mode 100644
index 000000000000..251b83732042
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.1/patch03
@@ -0,0 +1,107 @@
+diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
+--- mpfr-3.0.1-a/PATCHES 2011-05-05 00:00:35.000000000 +0000
++++ mpfr-3.0.1-b/PATCHES 2011-05-05 00:00:35.000000000 +0000
+@@ -0,0 +1 @@
++atan-expo-range
+diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
+--- mpfr-3.0.1-a/VERSION 2011-05-04 11:18:33.000000000 +0000
++++ mpfr-3.0.1-b/VERSION 2011-05-05 00:00:35.000000000 +0000
+@@ -1 +1 @@
+-3.0.1-p2
++3.0.1-p3
+diff -Naurd mpfr-3.0.1-a/atan.c mpfr-3.0.1-b/atan.c
+--- mpfr-3.0.1-a/atan.c 2011-04-04 10:19:18.000000000 +0000
++++ mpfr-3.0.1-b/atan.c 2011-05-05 00:00:35.000000000 +0000
+@@ -431,5 +431,5 @@
+ MPFR_GROUP_CLEAR (group);
+
+ MPFR_SAVE_EXPO_FREE (expo);
+- return mpfr_check_range (arctgt, inexact, rnd_mode);
++ return mpfr_check_range (atan, inexact, rnd_mode);
+ }
+diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
+--- mpfr-3.0.1-a/mpfr.h 2011-05-04 11:18:33.000000000 +0000
++++ mpfr-3.0.1-b/mpfr.h 2011-05-05 00:00:35.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.0.1-p2"
++#define MPFR_VERSION_STRING "3.0.1-p3"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.1-a/tests/tatan.c mpfr-3.0.1-b/tests/tatan.c
+--- mpfr-3.0.1-a/tests/tatan.c 2011-04-04 10:19:17.000000000 +0000
++++ mpfr-3.0.1-b/tests/tatan.c 2011-05-05 00:00:35.000000000 +0000
+@@ -535,6 +535,52 @@
+ mpfr_clears (a, x, y, (mpfr_ptr) 0);
+ }
+
++/* http://websympa.loria.fr/wwsympa/arc/mpfr/2011-05/msg00008.html
++ * Incorrect flags (in debug mode on a 32-bit machine, assertion failure).
++ */
++static void
++reduced_expo_range (void)
++{
++ mpfr_exp_t emin, emax;
++ mpfr_t x, y, ex_y;
++ int inex, ex_inex;
++ unsigned int flags, ex_flags;
++
++ emin = mpfr_get_emin ();
++ emax = mpfr_get_emax ();
++
++ mpfr_inits2 (12, x, y, ex_y, (mpfr_ptr) 0);
++ mpfr_set_str (x, "0.1e-5", 2, MPFR_RNDN);
++
++ mpfr_set_emin (-5);
++ mpfr_set_emax (-5);
++ mpfr_clear_flags ();
++ inex = mpfr_atan (y, x, MPFR_RNDN);
++ flags = __gmpfr_flags;
++ mpfr_set_emin (emin);
++ mpfr_set_emax (emax);
++
++ mpfr_set_str (ex_y, "0.1e-5", 2, MPFR_RNDN);
++ ex_inex = 1;
++ ex_flags = MPFR_FLAGS_INEXACT;
++
++ if (SIGN (inex) != ex_inex || flags != ex_flags ||
++ ! mpfr_equal_p (y, ex_y))
++ {
++ printf ("Error in reduced_expo_range\non x = ");
++ mpfr_dump (x);
++ printf ("Expected y = ");
++ mpfr_out_str (stdout, 2, 0, ex_y, MPFR_RNDN);
++ printf ("\n inex = %d, flags = %u\n", ex_inex, ex_flags);
++ printf ("Got y = ");
++ mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
++ printf ("\n inex = %d, flags = %u\n", SIGN (inex), flags);
++ exit (1);
++ }
++
++ mpfr_clears (x, y, ex_y, (mpfr_ptr) 0);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -546,6 +592,7 @@
+ smallvals_atan2 ();
+ atan2_bug_20071003 ();
+ atan2_different_prec ();
++ reduced_expo_range ();
+
+ test_generic_atan (2, 200, 17);
+ test_generic_atan2 (2, 200, 17);
+diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
+--- mpfr-3.0.1-a/version.c 2011-05-04 11:18:33.000000000 +0000
++++ mpfr-3.0.1-b/version.c 2011-05-05 00:00:35.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.1-p2";
++ return "3.0.1-p3";
+ }
diff --git a/dev-libs/mpfr/files/3.0.1/patch04 b/dev-libs/mpfr/files/3.0.1/patch04
new file mode 100644
index 000000000000..fd74087dc689
--- /dev/null
+++ b/dev-libs/mpfr/files/3.0.1/patch04
@@ -0,0 +1,47 @@
+diff -Naurd mpfr-3.0.1-a/PATCHES mpfr-3.0.1-b/PATCHES
+--- mpfr-3.0.1-a/PATCHES 2011-05-09 14:48:24.000000000 +0000
++++ mpfr-3.0.1-b/PATCHES 2011-05-09 14:48:24.000000000 +0000
+@@ -0,0 +1 @@
++texp-zero
+diff -Naurd mpfr-3.0.1-a/VERSION mpfr-3.0.1-b/VERSION
+--- mpfr-3.0.1-a/VERSION 2011-05-05 00:00:35.000000000 +0000
++++ mpfr-3.0.1-b/VERSION 2011-05-09 14:48:24.000000000 +0000
+@@ -1 +1 @@
+-3.0.1-p3
++3.0.1-p4
+diff -Naurd mpfr-3.0.1-a/mpfr.h mpfr-3.0.1-b/mpfr.h
+--- mpfr-3.0.1-a/mpfr.h 2011-05-05 00:00:35.000000000 +0000
++++ mpfr-3.0.1-b/mpfr.h 2011-05-09 14:48:24.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 0
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.0.1-p3"
++#define MPFR_VERSION_STRING "3.0.1-p4"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.0.1-a/tests/texp.c mpfr-3.0.1-b/tests/texp.c
+--- mpfr-3.0.1-a/tests/texp.c 2011-04-04 10:19:17.000000000 +0000
++++ mpfr-3.0.1-b/tests/texp.c 2011-05-09 14:48:24.000000000 +0000
+@@ -170,7 +170,9 @@
+ mpfr_set_prec (x, prec);
+ mpfr_set_prec (y, prec);
+ mpfr_set_prec (z, prec);
+- mpfr_urandomb (x, RANDS);
++ do
++ mpfr_urandomb (x, RANDS);
++ while (MPFR_IS_ZERO (x)); /* 0 is handled by mpfr_exp only */
+ rnd = RND_RAND ();
+ mpfr_exp_2 (y, x, rnd);
+ mpfr_exp_3 (z, x, rnd);
+diff -Naurd mpfr-3.0.1-a/version.c mpfr-3.0.1-b/version.c
+--- mpfr-3.0.1-a/version.c 2011-05-05 00:00:35.000000000 +0000
++++ mpfr-3.0.1-b/version.c 2011-05-09 14:48:24.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.0.1-p3";
++ return "3.0.1-p4";
+ }
diff --git a/dev-libs/mpfr/files/3.1.0/patch01 b/dev-libs/mpfr/files/3.1.0/patch01
new file mode 100644
index 000000000000..437b1a278adc
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch01
@@ -0,0 +1,50 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2011-10-05 21:39:57.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2011-10-05 21:39:57.000000000 +0000
+@@ -0,0 +1 @@
++mpfr_unlikely
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2011-10-03 08:17:15.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2011-10-05 21:39:57.000000000 +0000
+@@ -1 +1 @@
+-3.1.0
++3.1.0-p1
+diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h
+--- mpfr-3.1.0-a/src/mpfr-impl.h 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr-impl.h 2011-10-05 21:39:57.000000000 +0000
+@@ -988,10 +988,11 @@
+ ******************************************************/
+
+ /* Theses macros help the compiler to determine if a test is
+- * likely or unlikely. */
++ likely or unlikely. The !! is necessary in case x is larger
++ than a long. */
+ #if __MPFR_GNUC(3,0) || __MPFR_ICC(8,1,0)
+ # define MPFR_LIKELY(x) (__builtin_expect(!!(x),1))
+-# define MPFR_UNLIKELY(x) (__builtin_expect((x),0))
++# define MPFR_UNLIKELY(x) (__builtin_expect(!!(x),0))
+ #else
+ # define MPFR_LIKELY(x) (x)
+ # define MPFR_UNLIKELY(x) (x)
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2011-10-05 21:39:57.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0"
++#define MPFR_VERSION_STRING "3.1.0-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2011-10-05 21:39:57.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0";
++ return "3.1.0-p1";
+ }
diff --git a/dev-libs/mpfr/files/3.1.0/patch02 b/dev-libs/mpfr/files/3.1.0/patch02
new file mode 100644
index 000000000000..4714ac9b0d61
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch02
@@ -0,0 +1,96 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2011-10-14 10:43:32.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2011-10-14 10:43:32.000000000 +0000
+@@ -0,0 +1 @@
++lib-search-path
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2011-10-05 21:39:57.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2011-10-14 10:43:32.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p1
++3.1.0-p2
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2011-10-05 21:39:57.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2011-10-14 10:43:32.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p1"
++#define MPFR_VERSION_STRING "3.1.0-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2011-10-05 21:39:57.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2011-10-14 10:43:32.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p1";
++ return "3.1.0-p2";
+ }
+diff -Naurd mpfr-3.1.0-a/tests/Makefile.am mpfr-3.1.0-b/tests/Makefile.am
+--- mpfr-3.1.0-a/tests/Makefile.am 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/Makefile.am 2011-10-03 08:17:14.000000000 +0000
+@@ -65,8 +65,24 @@
+ TESTS = $(check_PROGRAMS)
+ TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
+
+-# Option to prevent libtool from generating wrapper scripts for the tests.
++# The -no-install option prevents libtool from generating wrapper scripts
++# for the tests.
+ # This is useful to easily run the test scripts under valgrind or gdb.
+ # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
+ # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
+-AM_LDFLAGS = -no-install
++#
++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
++# library is already installed in the corresponding lib directory: its
++# purpose is to make sure that the local .libs comes first in the library
++# search path (otherwise the tests are linked against the old MPFR library
++# by the LINK command -- see the generated Makefile). See:
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
++# and
++# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
++#
++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
+diff -Naurd mpfr-3.1.0-a/tests/Makefile.in mpfr-3.1.0-b/tests/Makefile.in
+--- mpfr-3.1.0-a/tests/Makefile.in 2011-10-03 08:17:35.000000000 +0000
++++ mpfr-3.1.0-b/tests/Makefile.in 2011-10-03 08:17:35.000000000 +0000
+@@ -1124,11 +1124,27 @@
+ TESTS = $(check_PROGRAMS)
+ TESTS_ENVIRONMENT = MPFR_QUIET=1 $(VALGRIND)
+
+-# Option to prevent libtool from generating wrapper scripts for the tests.
++# The -no-install option prevents libtool from generating wrapper scripts
++# for the tests.
+ # This is useful to easily run the test scripts under valgrind or gdb.
+ # See discussion http://thread.gmane.org/gmane.comp.lib.gnulib.bugs/28033
+ # http://article.gmane.org/gmane.comp.lib.gnulib.bugs/28140 in particular.
+-AM_LDFLAGS = -no-install
++#
++# The -L$(top_builddir)/src/.libs option is necessary for some platforms,
++# such as HP-UX, when --with-gmp or --with-gmp-lib is used and an old MPFR
++# library is already installed in the corresponding lib directory: its
++# purpose is to make sure that the local .libs comes first in the library
++# search path (otherwise the tests are linked against the old MPFR library
++# by the LINK command -- see the generated Makefile). See:
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00043.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00044.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00066.html
++# http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00065.html
++# and
++# http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9728
++#
++AM_LDFLAGS = -no-install -L$(top_builddir)/src/.libs
+ all: all-am
+
+ .SUFFIXES:
diff --git a/dev-libs/mpfr/files/3.1.0/patch03 b/dev-libs/mpfr/files/3.1.0/patch03
new file mode 100644
index 000000000000..aa1cfbc609dd
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch03
@@ -0,0 +1,247 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2011-11-03 15:15:11.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2011-11-03 15:15:11.000000000 +0000
+@@ -0,0 +1 @@
++vasprintf
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2011-10-14 10:43:32.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2011-11-03 15:15:11.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p2
++3.1.0-p3
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2011-10-14 10:43:32.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2011-11-03 15:15:11.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p2"
++#define MPFR_VERSION_STRING "3.1.0-p3"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/vasprintf.c mpfr-3.1.0-b/src/vasprintf.c
+--- mpfr-3.1.0-a/src/vasprintf.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/vasprintf.c 2011-11-03 15:15:11.000000000 +0000
+@@ -1178,7 +1178,7 @@
+ mpfr_exp_t exp;
+ char * str;
+ const int spec_g = (spec.spec == 'g' || spec.spec == 'G');
+- const int keep_trailing_zeros = spec_g && spec.alt;
++ const int keep_trailing_zeros = !spec_g || spec.alt;
+
+ /* WARNING: an empty precision field is forbidden (it means precision = 6
+ and it should have been changed to 6 before the function call) */
+@@ -1356,7 +1356,7 @@
+ else
+ /* 1 <= |p| */
+ {
+- size_t nsd; /* Number of significant digits */
++ size_t str_len;
+
+ /* Determine the position of the most significant decimal digit. */
+ exp = floor_log10 (p);
+@@ -1365,12 +1365,10 @@
+ /* P is too large to print all its integral part digits */
+ return -1;
+
+- np->ip_size = exp + 1;
+-
+- nsd = spec.prec + np->ip_size;
+ if (dec_info == NULL)
+- {
+- str = mpfr_get_str (NULL, &exp, 10, nsd, p, spec.rnd_mode);
++ { /* this case occurs with mpfr_printf ("%.0RUf", x) with x=9.5 */
++ str =
++ mpfr_get_str (NULL, &exp, 10, spec.prec+exp+1, p, spec.rnd_mode);
+ register_string (np->sl, str);
+ }
+ else
+@@ -1379,81 +1377,60 @@
+ str = dec_info->str;
+ }
+ np->ip_ptr = MPFR_IS_NEG (p) ? ++str : str; /* skip sign */
++ str_len = strlen (str);
++
++ /* integral part */
++ if (exp > str_len)
++ /* mpfr_get_str gives no trailing zero when p is rounded up to the next
++ power of 10 (p integer, so no fractional part) */
++ {
++ np->ip_trailing_zeros = exp - str_len;
++ np->ip_size = str_len;
++ }
++ else
++ np->ip_size = exp;
+
+ if (spec.group)
+ /* thousands separator in integral part */
+ np->thousands_sep = MPFR_THOUSANDS_SEPARATOR;
+
+- if (nsd == 0 || (spec_g && !spec.alt))
+- /* compute how much non-zero digits in integral and fractional
+- parts */
++ /* fractional part */
++ str += np->ip_size;
++ str_len -= np->ip_size;
++ if (!keep_trailing_zeros)
++ /* remove trailing zeros, if any */
+ {
+- size_t str_len;
+- str_len = strlen (str); /* note: the sign has been skipped */
+-
+- if (exp > str_len)
+- /* mpfr_get_str doesn't give the trailing zeros when p is a
+- multiple of 10 (p integer, so no fractional part) */
+- {
+- np->ip_trailing_zeros = exp - str_len;
+- np->ip_size = str_len;
+- if (spec.alt)
+- np->point = MPFR_DECIMAL_POINT;
+- }
+- else
+- /* str may contain some digits which are in fractional part */
++ char *ptr = str + str_len - 1; /* pointer to the last digit of
++ str */
++ while ((*ptr == '0') && (str_len != 0))
+ {
+- char *ptr;
+-
+- ptr = str + str_len - 1; /* points to the end of str */
+- str_len -= np->ip_size; /* number of digits in fractional
+- part */
+-
+- if (!keep_trailing_zeros)
+- /* remove trailing zeros, if any */
+- {
+- while ((*ptr == '0') && (str_len != 0))
+- {
+- --ptr;
+- --str_len;
+- }
+- }
+-
+- if (str_len > INT_MAX)
+- /* too many digits in fractional part */
+- return -1;
+-
+- if (str_len != 0)
+- /* some digits in fractional part */
+- {
+- np->point = MPFR_DECIMAL_POINT;
+- np->fp_ptr = str + np->ip_size;
+- np->fp_size = str_len;
+- }
++ --ptr;
++ --str_len;
+ }
+ }
+- else
+- /* spec.prec digits in fractional part */
++
++ if (str_len > 0)
++ /* some nonzero digits in fractional part */
+ {
+- if (np->ip_size == exp - 1)
+- /* the absolute value of the number has been rounded up to a power
+- of ten.
+- Insert an additional zero in integral part and put the rest of
+- them in fractional part. */
+- np->ip_trailing_zeros = 1;
++ if (str_len > INT_MAX)
++ /* too many digits in fractional part */
++ return -1;
+
+- if (spec.prec != 0)
+- {
+- MPFR_ASSERTD (np->ip_size + np->ip_trailing_zeros == exp);
+- MPFR_ASSERTD (np->ip_size + spec.prec == nsd);
++ np->point = MPFR_DECIMAL_POINT;
++ np->fp_ptr = str;
++ np->fp_size = str_len;
++ }
+
+- np->point = MPFR_DECIMAL_POINT;
+- np->fp_ptr = str + np->ip_size;
+- np->fp_size = spec.prec;
+- }
+- else if (spec.alt)
+- np->point = MPFR_DECIMAL_POINT;
++ if (keep_trailing_zeros && str_len < spec.prec)
++ /* add missing trailing zeros */
++ {
++ np->point = MPFR_DECIMAL_POINT;
++ np->fp_trailing_zeros = spec.prec - np->fp_size;
+ }
++
++ if (spec.alt)
++ /* add decimal point even if no digits follow it */
++ np->point = MPFR_DECIMAL_POINT;
+ }
+
+ return 0;
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2011-10-14 10:43:32.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2011-11-03 15:15:11.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p2";
++ return "3.1.0-p3";
+ }
+diff -Naurd mpfr-3.1.0-a/tests/tsprintf.c mpfr-3.1.0-b/tests/tsprintf.c
+--- mpfr-3.1.0-a/tests/tsprintf.c 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/tsprintf.c 2011-11-03 15:15:11.000000000 +0000
+@@ -475,6 +475,18 @@
+ check_sprintf ("-1.", "%- #0.1RG", x);
+
+ /* precision zero */
++ mpfr_set_d (x, 9.5, MPFR_RNDN);
++ check_sprintf ("9", "%.0RDf", x);
++ check_sprintf ("10", "%.0RUf", x);
++
++ mpfr_set_d (x, 19.5, MPFR_RNDN);
++ check_sprintf ("19", "%.0RDf", x);
++ check_sprintf ("20", "%.0RUf", x);
++
++ mpfr_set_d (x, 99.5, MPFR_RNDN);
++ check_sprintf ("99", "%.0RDf", x);
++ check_sprintf ("100", "%.0RUf", x);
++
+ mpfr_set_d (x, -9.5, MPFR_RNDN);
+ check_sprintf ("-10", "%.0RDf", x);
+ check_sprintf ("-10", "%.0RYf", x);
+@@ -1078,6 +1090,23 @@
+ mpfr_clear (x);
+ }
+
++static void
++bug20111102 (void)
++{
++ mpfr_t t;
++ char s[100];
++
++ mpfr_init2 (t, 84);
++ mpfr_set_str (t, "999.99999999999999999999", 10, MPFR_RNDN);
++ mpfr_sprintf (s, "%.20RNg", t);
++ if (strcmp (s, "1000") != 0)
++ {
++ printf ("Error in bug20111102, expected 1000, got %s\n", s);
++ exit (1);
++ }
++ mpfr_clear (t);
++}
++
+ /* In particular, the following test makes sure that the rounding
+ * for %Ra and %Rb is not done on the MPFR number itself (as it
+ * would overflow). Note: it has been reported on comp.std.c that
+@@ -1161,6 +1190,7 @@
+ locale = setlocale (LC_ALL, "C");
+ #endif
+
++ bug20111102 ();
+ native_types ();
+ hexadecimal ();
+ binary ();
diff --git a/dev-libs/mpfr/files/3.1.0/patch04 b/dev-libs/mpfr/files/3.1.0/patch04
new file mode 100644
index 000000000000..4b1ba087cf1b
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch04
@@ -0,0 +1,166 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2011-11-28 12:22:52.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2011-11-28 12:22:52.000000000 +0000
+@@ -0,0 +1 @@
++gmp41compat
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2011-11-03 15:15:11.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2011-11-28 12:22:52.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p3
++3.1.0-p4
+diff -Naurd mpfr-3.1.0-a/doc/mpfr.info mpfr-3.1.0-b/doc/mpfr.info
+--- mpfr-3.1.0-a/doc/mpfr.info 2011-10-03 09:43:04.000000000 +0000
++++ mpfr-3.1.0-b/doc/mpfr.info 2011-11-28 12:22:52.000000000 +0000
+@@ -2994,11 +2994,12 @@
+
+ * `mpfr_urandom' and `mpfr_urandomb' changed in MPFR 3.1. Their
+ behavior no longer depends on the platform (assuming this is also
+- true for GMP's random generator). As a consequence, the returned
+- values can be different between MPFR 3.1 and previous MPFR
+- versions. Note: as the reproducibility of these functions was not
+- specified before MPFR 3.1, the MPFR 3.1 behavior is _not_ regarded
+- as backward incompatible with previous versions.
++ true for GMP's random generator, which is not the case between GMP
++ 4.1 and 4.2 if `gmp_randinit_default' is used). As a consequence,
++ the returned values can be different between MPFR 3.1 and previous
++ MPFR versions. Note: as the reproducibility of these functions
++ was not specified before MPFR 3.1, the MPFR 3.1 behavior is _not_
++ regarded as backward incompatible with previous versions.
+
+
+ 
+@@ -4239,13 +4240,13 @@
+ Node: Type and Macro Changes129308
+ Node: Added Functions132029
+ Node: Changed Functions134972
+-Node: Removed Functions139167
+-Node: Other Changes139579
+-Node: Contributors141108
+-Node: References143574
+-Node: GNU Free Documentation License145315
+-Node: Concept Index167758
+-Node: Function and Type Index173677
++Node: Removed Functions139253
++Node: Other Changes139665
++Node: Contributors141194
++Node: References143660
++Node: GNU Free Documentation License145401
++Node: Concept Index167844
++Node: Function and Type Index173763
+ 
+ End Tag Table
+
+diff -Naurd mpfr-3.1.0-a/doc/mpfr.texi mpfr-3.1.0-b/doc/mpfr.texi
+--- mpfr-3.1.0-a/doc/mpfr.texi 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/doc/mpfr.texi 2011-11-28 12:22:52.000000000 +0000
+@@ -3466,8 +3466,9 @@
+ a lack of specification.
+
+ @item @code{mpfr_urandom} and @code{mpfr_urandomb} changed in MPFR 3.1.
+-Their behavior no longer depends on the platform (assuming this is also
+-true for GMP's random generator). As a consequence, the returned values
++Their behavior no longer depends on the platform (assuming this is also true
++for GMP's random generator, which is not the case between GMP 4.1 and 4.2 if
++@code{gmp_randinit_default} is used). As a consequence, the returned values
+ can be different between MPFR 3.1 and previous MPFR versions.
+ Note: as the reproducibility of these functions was not specified
+ before MPFR 3.1, the MPFR 3.1 behavior is @emph{not} regarded as
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2011-11-03 15:15:11.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2011-11-28 12:22:52.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p3"
++#define MPFR_VERSION_STRING "3.1.0-p4"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2011-11-03 15:15:11.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2011-11-28 12:22:52.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p3";
++ return "3.1.0-p4";
+ }
+diff -Naurd mpfr-3.1.0-a/tests/trandom.c mpfr-3.1.0-b/tests/trandom.c
+--- mpfr-3.1.0-a/tests/trandom.c 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/trandom.c 2011-11-28 12:22:52.000000000 +0000
+@@ -114,21 +114,29 @@
+ mpfr_t x;
+ gmp_randstate_t s;
+
++#if __MPFR_GMP(4,2,0)
++# define C1 "0.895943"
++# define C2 "0.848824"
++#else
++# define C1 "0.479652"
++# define C2 "0.648529"
++#endif
++
+ gmp_randinit_default (s);
+ gmp_randseed_ui (s, 42);
+ mpfr_init2 (x, 17);
+ mpfr_urandomb (x, s);
+- if (mpfr_cmp_str1 (x, "0.895943") != 0)
++ if (mpfr_cmp_str1 (x, C1) != 0)
+ {
+- printf ("Error in bug20100914, expected 0.895943, got ");
++ printf ("Error in bug20100914, expected " C1 ", got ");
+ mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
+ printf ("\n");
+ exit (1);
+ }
+ mpfr_urandomb (x, s);
+- if (mpfr_cmp_str1 (x, "0.848824") != 0)
++ if (mpfr_cmp_str1 (x, C2) != 0)
+ {
+- printf ("Error in bug20100914, expected 0.848824, got ");
++ printf ("Error in bug20100914, expected " C2 ", got ");
+ mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
+ printf ("\n");
+ exit (1);
+diff -Naurd mpfr-3.1.0-a/tests/turandom.c mpfr-3.1.0-b/tests/turandom.c
+--- mpfr-3.1.0-a/tests/turandom.c 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/turandom.c 2011-11-28 12:22:52.000000000 +0000
+@@ -160,23 +160,29 @@
+ mpfr_t x;
+ gmp_randstate_t s;
+
++#if __MPFR_GMP(4,2,0)
++# define C1 "0.8488312"
++# define C2 "0.8156509"
++#else
++# define C1 "0.6485367"
++# define C2 "0.9362717"
++#endif
++
+ gmp_randinit_default (s);
+ gmp_randseed_ui (s, 42);
+ mpfr_init2 (x, 17);
+ mpfr_urandom (x, s, MPFR_RNDN);
+- /* the following values are obtained on a 32-bit computer, we should get
+- the same values on a 64-bit computer */
+- if (mpfr_cmp_str1 (x, "0.8488312") != 0)
++ if (mpfr_cmp_str1 (x, C1) != 0)
+ {
+- printf ("Error in bug20100914, expected 0.8488312, got ");
++ printf ("Error in bug20100914, expected " C1 ", got ");
+ mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
+ printf ("\n");
+ exit (1);
+ }
+ mpfr_urandom (x, s, MPFR_RNDN);
+- if (mpfr_cmp_str1 (x, "0.8156509") != 0)
++ if (mpfr_cmp_str1 (x, C2) != 0)
+ {
+- printf ("Error in bug20100914, expected 0.8156509, got ");
++ printf ("Error in bug20100914, expected " C2 ", got ");
+ mpfr_out_str (stdout, 10, 0, x, MPFR_RNDN);
+ printf ("\n");
+ exit (1);
diff --git a/dev-libs/mpfr/files/3.1.0/patch05 b/dev-libs/mpfr/files/3.1.0/patch05
new file mode 100644
index 000000000000..c664cee3526c
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch05
@@ -0,0 +1,69 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2012-02-24 12:44:49.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2012-02-24 12:44:49.000000000 +0000
+@@ -0,0 +1 @@
++logging-freeze
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2011-11-28 12:22:52.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2012-02-24 12:44:49.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p4
++3.1.0-p5
+diff -Naurd mpfr-3.1.0-a/src/add_d.c mpfr-3.1.0-b/src/add_d.c
+--- mpfr-3.1.0-a/src/add_d.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/add_d.c 2012-02-24 12:44:49.000000000 +0000
+@@ -34,7 +34,7 @@
+ (("b[%Pu]=%.*Rg c=%.20g rnd=%d",
+ mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode),
+ ("a[%Pu]=%.*Rg inexact=%d",
+- mpfr_get_prec (a), mpfr_get_prec, a, inexact));
++ mpfr_get_prec (a), mpfr_log_prec, a, inexact));
+
+ MPFR_SAVE_EXPO_MARK (expo);
+
+diff -Naurd mpfr-3.1.0-a/src/add_ui.c mpfr-3.1.0-b/src/add_ui.c
+--- mpfr-3.1.0-a/src/add_ui.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/add_ui.c 2012-02-24 12:44:49.000000000 +0000
+@@ -29,7 +29,7 @@
+ MPFR_LOG_FUNC
+ (("x[%Pu]=%.*Rg u=%d rnd=%d",
+ mpfr_get_prec(x), mpfr_log_prec, x, u, rnd_mode),
+- ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_get_prec, y));
++ ("y[%Pu]=%.*Rg", mpfr_get_prec (y), mpfr_log_prec, y));
+
+ if (MPFR_LIKELY(u != 0) ) /* if u=0, do nothing */
+ {
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2011-11-28 12:22:52.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2012-02-24 12:44:49.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p4"
++#define MPFR_VERSION_STRING "3.1.0-p5"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/mul_d.c mpfr-3.1.0-b/src/mul_d.c
+--- mpfr-3.1.0-a/src/mul_d.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/mul_d.c 2012-02-24 12:44:49.000000000 +0000
+@@ -34,7 +34,7 @@
+ (("b[%Pu]=%.*Rg c=%.20g rnd=%d",
+ mpfr_get_prec(b), mpfr_log_prec, b, c, rnd_mode),
+ ("a[%Pu]=%.*Rg inexact=%d",
+- mpfr_get_prec (a), mpfr_get_prec, a, inexact));
++ mpfr_get_prec (a), mpfr_log_prec, a, inexact));
+
+ MPFR_SAVE_EXPO_MARK (expo);
+
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2011-11-28 12:22:52.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2012-02-24 12:44:49.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p4";
++ return "3.1.0-p5";
+ }
diff --git a/dev-libs/mpfr/files/3.1.0/patch06 b/dev-libs/mpfr/files/3.1.0/patch06
new file mode 100644
index 000000000000..0f4bfad6718a
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch06
@@ -0,0 +1,45 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2012-02-24 13:50:05.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2012-02-24 13:50:05.000000000 +0000
+@@ -0,0 +1 @@
++logging-varfmt
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2012-02-24 12:44:49.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2012-02-24 13:50:05.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p5
++3.1.0-p6
+diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h
+--- mpfr-3.1.0-a/src/mpfr-impl.h 2011-10-05 21:39:57.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr-impl.h 2012-02-24 13:50:05.000000000 +0000
+@@ -1592,7 +1592,7 @@
+ do \
+ if ((MPFR_LOG_INTERNAL_F & mpfr_log_type) && \
+ (mpfr_log_current <= mpfr_log_level)) \
+- LOG_PRINT ("%s.%d:%s[%#Pu]=%.*Rf\n", __func__, __LINE__, \
++ LOG_PRINT ("%s.%d:%s[%#Pu]=%.*Rg\n", __func__, __LINE__, \
+ #x, mpfr_get_prec (x), mpfr_log_prec, x); \
+ while (0)
+
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2012-02-24 12:44:49.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2012-02-24 13:50:05.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p5"
++#define MPFR_VERSION_STRING "3.1.0-p6"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2012-02-24 12:44:49.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2012-02-24 13:50:05.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p5";
++ return "3.1.0-p6";
+ }
diff --git a/dev-libs/mpfr/files/3.1.0/patch07 b/dev-libs/mpfr/files/3.1.0/patch07
new file mode 100644
index 000000000000..08e7b57d53c4
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.0/patch07
@@ -0,0 +1,591 @@
+diff -Naurd mpfr-3.1.0-a/PATCHES mpfr-3.1.0-b/PATCHES
+--- mpfr-3.1.0-a/PATCHES 2012-03-08 15:17:03.000000000 +0000
++++ mpfr-3.1.0-b/PATCHES 2012-03-08 15:17:03.000000000 +0000
+@@ -0,0 +1 @@
++large-prec
+diff -Naurd mpfr-3.1.0-a/VERSION mpfr-3.1.0-b/VERSION
+--- mpfr-3.1.0-a/VERSION 2012-02-24 13:50:05.000000000 +0000
++++ mpfr-3.1.0-b/VERSION 2012-03-08 15:17:03.000000000 +0000
+@@ -1 +1 @@
+-3.1.0-p6
++3.1.0-p7
+diff -Naurd mpfr-3.1.0-a/src/add1.c mpfr-3.1.0-b/src/add1.c
+--- mpfr-3.1.0-a/src/add1.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/add1.c 2012-03-08 15:17:03.000000000 +0000
+@@ -44,12 +44,12 @@
+ bq = MPFR_PREC(b);
+ cq = MPFR_PREC(c);
+
+- an = (aq-1)/GMP_NUMB_BITS+1; /* number of limbs of a */
++ an = MPFR_PREC2LIMBS (aq); /* number of limbs of a */
+ aq2 = (mpfr_prec_t) an * GMP_NUMB_BITS;
+ sh = aq2 - aq; /* non-significant bits in low limb */
+
+- bn = (bq-1)/GMP_NUMB_BITS+1; /* number of limbs of b */
+- cn = (cq-1)/GMP_NUMB_BITS+1; /* number of limbs of c */
++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */
++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */
+
+ ap = MPFR_MANT(a);
+ bp = MPFR_MANT(b);
+@@ -124,7 +124,7 @@
+ dif = aq2 - diff_exp;
+ /* dif is the number of bits of c which overlap with a' */
+
+- difn = (dif-1)/GMP_NUMB_BITS + 1;
++ difn = MPFR_PREC2LIMBS (dif);
+ /* only the highest difn limbs from c have to be considered */
+ if (MPFR_UNLIKELY(difn > cn))
+ {
+diff -Naurd mpfr-3.1.0-a/src/add1sp.c mpfr-3.1.0-b/src/add1sp.c
+--- mpfr-3.1.0-a/src/add1sp.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/add1sp.c 2012-03-08 15:17:03.000000000 +0000
+@@ -107,7 +107,7 @@
+
+ /* Read prec and num of limbs */
+ p = MPFR_PREC(b);
+- n = (p+GMP_NUMB_BITS-1)/GMP_NUMB_BITS;
++ n = MPFR_PREC2LIMBS (p);
+ MPFR_UNSIGNED_MINUS_MODULO(sh, p);
+ bx = MPFR_GET_EXP(b);
+ d = (mpfr_uexp_t) (bx - MPFR_GET_EXP(c));
+diff -Naurd mpfr-3.1.0-a/src/agm.c mpfr-3.1.0-b/src/agm.c
+--- mpfr-3.1.0-a/src/agm.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/agm.c 2012-03-08 15:17:03.000000000 +0000
+@@ -91,7 +91,7 @@
+ q = MPFR_PREC(r);
+ p = q + MPFR_INT_CEIL_LOG2(q) + 15;
+ MPFR_ASSERTD (p >= 7); /* see algorithms.tex */
+- s = (p - 1) / GMP_NUMB_BITS + 1;
++ s = MPFR_PREC2LIMBS (p);
+
+ /* b (op2) and a (op1) are the 2 operands but we want b >= a */
+ compare = mpfr_cmp (op1, op2);
+@@ -285,7 +285,7 @@
+
+ /* Next iteration */
+ MPFR_ZIV_NEXT (loop, p);
+- s = (p - 1) / GMP_NUMB_BITS + 1;
++ s = MPFR_PREC2LIMBS (p);
+ }
+ MPFR_ZIV_FREE (loop);
+
+diff -Naurd mpfr-3.1.0-a/src/eq.c mpfr-3.1.0-b/src/eq.c
+--- mpfr-3.1.0-a/src/eq.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/eq.c 2012-03-08 15:17:03.000000000 +0000
+@@ -56,8 +56,8 @@
+ if (uexp != vexp)
+ return 0; /* no bit agree */
+
+- usize = (MPFR_PREC(u) - 1) / GMP_NUMB_BITS + 1;
+- vsize = (MPFR_PREC(v) - 1) / GMP_NUMB_BITS + 1;
++ usize = MPFR_LIMB_SIZE (u);
++ vsize = MPFR_LIMB_SIZE (v);
+
+ if (vsize > usize) /* exchange u and v */
+ {
+diff -Naurd mpfr-3.1.0-a/src/exp.c mpfr-3.1.0-b/src/exp.c
+--- mpfr-3.1.0-a/src/exp.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/exp.c 2012-03-08 15:17:03.000000000 +0000
+@@ -133,7 +133,7 @@
+ mp_size_t yn;
+ int sh;
+
+- yn = 1 + (MPFR_PREC(y) - 1) / GMP_NUMB_BITS;
++ yn = MPFR_LIMB_SIZE (y);
+ sh = (mpfr_prec_t) yn * GMP_NUMB_BITS - MPFR_PREC(y);
+ MPFR_MANT(y)[0] += MPFR_LIMB_ONE << sh;
+ inexact = 1;
+diff -Naurd mpfr-3.1.0-a/src/get_d.c mpfr-3.1.0-b/src/get_d.c
+--- mpfr-3.1.0-a/src/get_d.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/get_d.c 2012-03-08 15:17:03.000000000 +0000
+@@ -100,7 +100,7 @@
+ nbits += (1021 + e);
+ MPFR_ASSERTD (nbits >= 1);
+ }
+- np = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
++ np = MPFR_PREC2LIMBS (nbits);
+ MPFR_ASSERTD ( np <= MPFR_LIMBS_PER_DOUBLE );
+ carry = mpfr_round_raw_4 (tp, MPFR_MANT(src), MPFR_PREC(src), negative,
+ nbits, rnd_mode);
+diff -Naurd mpfr-3.1.0-a/src/get_flt.c mpfr-3.1.0-b/src/get_flt.c
+--- mpfr-3.1.0-a/src/get_flt.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/get_flt.c 2012-03-08 15:17:03.000000000 +0000
+@@ -92,7 +92,7 @@
+ nbits += (125 + e);
+ MPFR_ASSERTD (nbits >= 1);
+ }
+- np = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
++ np = MPFR_PREC2LIMBS (nbits);
+ MPFR_ASSERTD(np <= MPFR_LIMBS_PER_FLT);
+ carry = mpfr_round_raw_4 (tp, MPFR_MANT(src), MPFR_PREC(src), negative,
+ nbits, rnd_mode);
+diff -Naurd mpfr-3.1.0-a/src/get_str.c mpfr-3.1.0-b/src/get_str.c
+--- mpfr-3.1.0-a/src/get_str.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/get_str.c 2012-03-08 15:17:03.000000000 +0000
+@@ -2351,7 +2351,7 @@
+
+ /* the first digit will contain only r bits */
+ prec = (m - 1) * pow2 + r; /* total number of bits */
+- n = (prec - 1) / GMP_NUMB_BITS + 1;
++ n = MPFR_PREC2LIMBS (prec);
+
+ MPFR_TMP_MARK (marker);
+ x1 = MPFR_TMP_LIMBS_ALLOC (n + 1);
+@@ -2417,12 +2417,12 @@
+ exact = 1;
+
+ /* number of limbs */
+- n = 1 + (prec - 1) / GMP_NUMB_BITS;
++ n = MPFR_PREC2LIMBS (prec);
+
+ /* a will contain the approximation of the mantissa */
+ a = MPFR_TMP_LIMBS_ALLOC (n);
+
+- nx = 1 + (MPFR_PREC(x) - 1) / GMP_NUMB_BITS;
++ nx = MPFR_LIMB_SIZE (x);
+
+ if ((mpfr_exp_t) m == g) /* final exponent is 0, no multiplication or
+ division to perform */
+diff -Naurd mpfr-3.1.0-a/src/init2.c mpfr-3.1.0-b/src/init2.c
+--- mpfr-3.1.0-a/src/init2.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/init2.c 2012-03-08 15:17:03.000000000 +0000
+@@ -51,7 +51,7 @@
+ which both have an odd mantissa */
+ MPFR_ASSERTN(p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX);
+
+- xsize = (mp_size_t) ((p - 1) / GMP_NUMB_BITS) + 1;
++ xsize = MPFR_PREC2LIMBS (p);
+ tmp = (mpfr_limb_ptr) (*__gmp_allocate_func)(MPFR_MALLOC_SIZE(xsize));
+
+ MPFR_PREC(x) = p; /* Set prec */
+diff -Naurd mpfr-3.1.0-a/src/lngamma.c mpfr-3.1.0-b/src/lngamma.c
+--- mpfr-3.1.0-a/src/lngamma.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/lngamma.c 2012-03-08 15:17:03.000000000 +0000
+@@ -67,7 +67,7 @@
+
+ /* Now, the unit bit is represented. */
+
+- prec = ((prec - 1) / GMP_NUMB_BITS + 1) * GMP_NUMB_BITS - expo;
++ prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo;
+ /* number of represented fractional bits (including the trailing 0's) */
+
+ x0 = *(MPFR_MANT (x) + prec / GMP_NUMB_BITS);
+diff -Naurd mpfr-3.1.0-a/src/mpfr-impl.h mpfr-3.1.0-b/src/mpfr-impl.h
+--- mpfr-3.1.0-a/src/mpfr-impl.h 2012-02-24 13:50:05.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr-impl.h 2012-03-09 12:06:26.000000000 +0000
+@@ -646,10 +646,24 @@
+ **************** mpfr_t properties *******************
+ ******************************************************/
+
++/* In the following macro, p is usually a mpfr_prec_t, but this macro
++ works with other integer types (without integer overflow). Checking
++ that p >= 1 in debug mode is useful here because this macro can be
++ used on a computed precision (in particular, this formula does not
++ work for a degenerate case p = 0, and could give different results
++ on different platforms). But let us not use an assertion checking
++ in the MPFR_LAST_LIMB() and MPFR_LIMB_SIZE() macros below to avoid
++ too much expansion for assertions (in practice, this should be a
++ problem just when testing MPFR with the --enable-assert configure
++ option and the -ansi -pedantic-errors gcc compiler flags). */
++#define MPFR_PREC2LIMBS(p) \
++ (MPFR_ASSERTD ((p) >= 1), ((p) - 1) / GMP_NUMB_BITS + 1)
++
+ #define MPFR_PREC(x) ((x)->_mpfr_prec)
+ #define MPFR_EXP(x) ((x)->_mpfr_exp)
+ #define MPFR_MANT(x) ((x)->_mpfr_d)
+-#define MPFR_LIMB_SIZE(x) ((MPFR_PREC((x))-1)/GMP_NUMB_BITS+1)
++#define MPFR_LAST_LIMB(x) ((MPFR_PREC (x) - 1) / GMP_NUMB_BITS)
++#define MPFR_LIMB_SIZE(x) (MPFR_LAST_LIMB (x) + 1)
+
+
+ /******************************************************
+@@ -749,7 +763,8 @@
+ #define MPFR_IS_FP(x) (!MPFR_IS_NAN(x) && !MPFR_IS_INF(x))
+ #define MPFR_IS_SINGULAR(x) (MPFR_EXP(x) <= MPFR_EXP_INF)
+ #define MPFR_IS_PURE_FP(x) (!MPFR_IS_SINGULAR(x) && \
+- (MPFR_ASSERTD (MPFR_MANT(x)[MPFR_LIMB_SIZE(x)-1] & MPFR_LIMB_HIGHBIT), 1))
++ (MPFR_ASSERTD ((MPFR_MANT(x)[MPFR_LAST_LIMB(x)] \
++ & MPFR_LIMB_HIGHBIT) != 0), 1))
+
+ #define MPFR_ARE_SINGULAR(x,y) \
+ (MPFR_UNLIKELY(MPFR_IS_SINGULAR(x)) || MPFR_UNLIKELY(MPFR_IS_SINGULAR(y)))
+@@ -1061,7 +1076,7 @@
+ /* Set a number to 1 (Fast) - It doesn't check if 1 is in the exponent range */
+ #define MPFR_SET_ONE(x) \
+ do { \
+- mp_size_t _size = MPFR_LIMB_SIZE(x) - 1; \
++ mp_size_t _size = MPFR_LAST_LIMB(x); \
+ MPFR_SET_POS(x); \
+ MPFR_EXP(x) = 1; \
+ MPN_ZERO ( MPFR_MANT(x), _size); \
+@@ -1213,8 +1228,8 @@
+ _destp = MPFR_MANT (dest); \
+ if (MPFR_UNLIKELY (_destprec >= _srcprec)) \
+ { \
+- _srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
+- _dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS - _srcs; \
++ _srcs = MPFR_PREC2LIMBS (_srcprec); \
++ _dests = MPFR_PREC2LIMBS (_destprec) - _srcs; \
+ MPN_COPY (_destp + _dests, srcp, _srcs); \
+ MPN_ZERO (_destp, _dests); \
+ inexact = 0; \
+@@ -1227,8 +1242,8 @@
+ mp_limb_t _rb, _sb, _ulp; \
+ \
+ /* Compute Position and shift */ \
+- _srcs = (_srcprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
+- _dests = (_destprec + GMP_NUMB_BITS-1)/GMP_NUMB_BITS; \
++ _srcs = MPFR_PREC2LIMBS (_srcprec); \
++ _dests = MPFR_PREC2LIMBS (_destprec); \
+ MPFR_UNSIGNED_MINUS_MODULO (_sh, _destprec); \
+ _sp = (srcp) + _srcs - _dests; \
+ \
+@@ -1372,7 +1387,7 @@
+ if (MPFR_LIKELY (MPFR_PREC (dest) == MPFR_PREC (src))) \
+ { \
+ MPN_COPY (MPFR_MANT (dest), MPFR_MANT (src), \
+- (MPFR_PREC (src) + GMP_NUMB_BITS-1)/GMP_NUMB_BITS); \
++ MPFR_LIMB_SIZE (src)); \
+ inexact = 0; \
+ } \
+ else \
+@@ -1682,7 +1697,7 @@
+ MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \
+ if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \
+ mpfr_abort_prec_max (); \
+- _size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \
++ _size = MPFR_PREC2LIMBS (_prec); \
+ if (MPFR_UNLIKELY (_size * (num) > MPFR_GROUP_STATIC_SIZE)) \
+ { \
+ (g).alloc = (num) * _size * sizeof (mp_limb_t); \
+@@ -1733,7 +1748,7 @@
+ MPFR_ASSERTD (_prec >= MPFR_PREC_MIN); \
+ if (MPFR_UNLIKELY (_prec > MPFR_PREC_MAX)) \
+ mpfr_abort_prec_max (); \
+- _size = (mpfr_prec_t) (_prec + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; \
++ _size = MPFR_PREC2LIMBS (_prec); \
+ (g).alloc = (num) * _size * sizeof (mp_limb_t); \
+ if (MPFR_LIKELY (_oalloc == 0)) \
+ (g).mant = (mp_limb_t *) (*__gmp_allocate_func) ((g).alloc); \
+@@ -1886,7 +1901,7 @@
+ MPFR_NORETURN_ATTR;
+
+ __MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mpfr_limb_ptr, gmp_randstate_t,
+- unsigned long));
++ mpfr_prec_t));
+
+ __MPFR_DECLSPEC mpz_t* mpfr_bernoulli_internal _MPFR_PROTO((mpz_t*,
+ unsigned long));
+diff -Naurd mpfr-3.1.0-a/src/mpfr.h mpfr-3.1.0-b/src/mpfr.h
+--- mpfr-3.1.0-a/src/mpfr.h 2012-02-24 13:50:05.000000000 +0000
++++ mpfr-3.1.0-b/src/mpfr.h 2012-03-08 15:17:03.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 0
+-#define MPFR_VERSION_STRING "3.1.0-p6"
++#define MPFR_VERSION_STRING "3.1.0-p7"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.0-a/src/mul.c mpfr-3.1.0-b/src/mul.c
+--- mpfr-3.1.0-a/src/mul.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/mul.c 2012-03-08 15:17:03.000000000 +0000
+@@ -93,15 +93,15 @@
+
+ ax = MPFR_GET_EXP (b) + MPFR_GET_EXP (c);
+
+- bq = MPFR_PREC(b);
+- cq = MPFR_PREC(c);
++ bq = MPFR_PREC (b);
++ cq = MPFR_PREC (c);
+
+- MPFR_ASSERTD(bq+cq > bq); /* PREC_MAX is /2 so no integer overflow */
++ MPFR_ASSERTN ((mpfr_uprec_t) bq + cq <= MPFR_PREC_MAX);
+
+- bn = (bq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of b */
+- cn = (cq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of c */
++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */
++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */
+ k = bn + cn; /* effective nb of limbs used by b*c (= tn or tn+1) below */
+- tn = (bq + cq + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
++ tn = MPFR_PREC2LIMBS (bq + cq);
+ /* <= k, thus no int overflow */
+ MPFR_ASSERTD(tn <= k);
+
+@@ -292,12 +292,12 @@
+ bq = MPFR_PREC (b);
+ cq = MPFR_PREC (c);
+
+- MPFR_ASSERTD (bq+cq > bq); /* PREC_MAX is /2 so no integer overflow */
++ MPFR_ASSERTN ((mpfr_uprec_t) bq + cq <= MPFR_PREC_MAX);
+
+- bn = (bq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of b */
+- cn = (cq+GMP_NUMB_BITS-1)/GMP_NUMB_BITS; /* number of limbs of c */
++ bn = MPFR_PREC2LIMBS (bq); /* number of limbs of b */
++ cn = MPFR_PREC2LIMBS (cq); /* number of limbs of c */
+ k = bn + cn; /* effective nb of limbs used by b*c (= tn or tn+1) below */
+- tn = (bq + cq + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
++ tn = MPFR_PREC2LIMBS (bq + cq);
+ MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */
+
+ /* Check for no size_t overflow*/
+diff -Naurd mpfr-3.1.0-a/src/pow.c mpfr-3.1.0-b/src/pow.c
+--- mpfr-3.1.0-a/src/pow.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/pow.c 2012-03-08 15:17:03.000000000 +0000
+@@ -136,7 +136,7 @@
+ (b) all the 'z' bits are zero
+ */
+
+- prec = ((prec - 1) / GMP_NUMB_BITS + 1) * GMP_NUMB_BITS - expo;
++ prec = MPFR_PREC2LIMBS (prec) * GMP_NUMB_BITS - expo;
+ /* number of z+0 bits */
+
+ yn = prec / GMP_NUMB_BITS;
+diff -Naurd mpfr-3.1.0-a/src/print_raw.c mpfr-3.1.0-b/src/print_raw.c
+--- mpfr-3.1.0-a/src/print_raw.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/print_raw.c 2012-03-08 15:17:03.000000000 +0000
+@@ -84,7 +84,7 @@
+ int i;
+ mpfr_prec_t count = 0;
+ char c;
+- mp_size_t n = (r - 1) / GMP_NUMB_BITS + 1;
++ mp_size_t n = MPFR_PREC2LIMBS (r);
+
+ printf("%s ", str);
+ for(n-- ; n>=0 ; n--)
+@@ -109,7 +109,7 @@
+ int i;
+ mpfr_prec_t count = 0;
+ char c;
+- mp_size_t n = (r - 1) / GMP_NUMB_BITS + 1;
++ mp_size_t n = MPFR_PREC2LIMBS (r);
+
+ for(n-- ; n>=0 ; n--)
+ {
+diff -Naurd mpfr-3.1.0-a/src/round_prec.c mpfr-3.1.0-b/src/round_prec.c
+--- mpfr-3.1.0-a/src/round_prec.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/round_prec.c 2012-03-08 15:17:03.000000000 +0000
+@@ -55,12 +55,12 @@
+
+ MPFR_ASSERTN(prec >= MPFR_PREC_MIN && prec <= MPFR_PREC_MAX);
+
+- nw = 1 + (prec - 1) / GMP_NUMB_BITS; /* needed allocated limbs */
++ nw = MPFR_PREC2LIMBS (prec); /* needed allocated limbs */
+
+ /* check if x has enough allocated space for the significand */
+ /* Get the number of limbs from the precision.
+ (Compatible with all allocation methods) */
+- ow = (MPFR_PREC (x) + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS;
++ ow = MPFR_LIMB_SIZE (x);
+ if (nw > ow)
+ {
+ /* FIXME: Variable can't be created using custom allocation,
+diff -Naurd mpfr-3.1.0-a/src/round_raw_generic.c mpfr-3.1.0-b/src/round_raw_generic.c
+--- mpfr-3.1.0-a/src/round_raw_generic.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/round_raw_generic.c 2012-03-08 15:17:03.000000000 +0000
+@@ -80,7 +80,7 @@
+ (xprec <= yprec || MPFR_IS_LIKE_RNDZ (rnd_mode, neg)))
+ return 0;
+
+- xsize = (xprec-1)/GMP_NUMB_BITS + 1;
++ xsize = MPFR_PREC2LIMBS (xprec);
+ nw = yprec / GMP_NUMB_BITS;
+ rw = yprec & (GMP_NUMB_BITS - 1);
+
+diff -Naurd mpfr-3.1.0-a/src/set.c mpfr-3.1.0-b/src/set.c
+--- mpfr-3.1.0-a/src/set.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/set.c 2012-03-08 15:17:03.000000000 +0000
+@@ -48,8 +48,7 @@
+ /* Same precision and b is not singular:
+ * just copy the mantissa, and set the exponent and the sign
+ * The result is exact. */
+- MPN_COPY (MPFR_MANT (a), MPFR_MANT (b),
+- (MPFR_PREC (b) + GMP_NUMB_BITS-1)/GMP_NUMB_BITS);
++ MPN_COPY (MPFR_MANT (a), MPFR_MANT (b), MPFR_LIMB_SIZE (b));
+ MPFR_RET (0);
+ }
+ else
+diff -Naurd mpfr-3.1.0-a/src/set_f.c mpfr-3.1.0-b/src/set_f.c
+--- mpfr-3.1.0-a/src/set_f.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/set_f.c 2012-03-08 15:17:03.000000000 +0000
+@@ -43,7 +43,7 @@
+ if (SIZ(x) * MPFR_FROM_SIGN_TO_INT(MPFR_SIGN(y)) < 0)
+ MPFR_CHANGE_SIGN (y);
+
+- sy = 1 + (MPFR_PREC(y) - 1) / GMP_NUMB_BITS;
++ sy = MPFR_LIMB_SIZE (y);
+ my = MPFR_MANT(y);
+ mx = PTR(x);
+
+diff -Naurd mpfr-3.1.0-a/src/set_prec.c mpfr-3.1.0-b/src/set_prec.c
+--- mpfr-3.1.0-a/src/set_prec.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/set_prec.c 2012-03-08 15:17:03.000000000 +0000
+@@ -32,7 +32,7 @@
+ MPFR_ASSERTN (p >= MPFR_PREC_MIN && p <= MPFR_PREC_MAX);
+
+ /* Calculate the new number of limbs */
+- xsize = (p - 1) / GMP_NUMB_BITS + 1;
++ xsize = MPFR_PREC2LIMBS (p);
+
+ /* Realloc only if the new size is greater than the old */
+ xoldsize = MPFR_GET_ALLOC_SIZE (x);
+diff -Naurd mpfr-3.1.0-a/src/setmax.c mpfr-3.1.0-b/src/setmax.c
+--- mpfr-3.1.0-a/src/setmax.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/setmax.c 2012-03-08 15:17:03.000000000 +0000
+@@ -32,7 +32,7 @@
+ mp_limb_t *xp;
+
+ MPFR_SET_EXP (x, e);
+- xn = 1 + (MPFR_PREC(x) - 1) / GMP_NUMB_BITS;
++ xn = MPFR_LIMB_SIZE (x);
+ sh = (mpfr_prec_t) xn * GMP_NUMB_BITS - MPFR_PREC(x);
+ xp = MPFR_MANT(x);
+ xp[0] = MP_LIMB_T_MAX << sh;
+diff -Naurd mpfr-3.1.0-a/src/sqr.c mpfr-3.1.0-b/src/sqr.c
+--- mpfr-3.1.0-a/src/sqr.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/sqr.c 2012-03-08 15:17:03.000000000 +0000
+@@ -56,11 +56,11 @@
+ ax = 2 * MPFR_GET_EXP (b);
+ bq = MPFR_PREC(b);
+
+- MPFR_ASSERTD (2 * bq > bq); /* PREC_MAX is /2 so no integer overflow */
++ MPFR_ASSERTN (2 * (mpfr_uprec_t) bq <= MPFR_PREC_MAX);
+
+- bn = MPFR_LIMB_SIZE(b); /* number of limbs of b */
+- tn = 1 + (2 * bq - 1) / GMP_NUMB_BITS; /* number of limbs of square,
+- 2*bn or 2*bn-1 */
++ bn = MPFR_LIMB_SIZE (b); /* number of limbs of b */
++ tn = MPFR_PREC2LIMBS (2 * bq); /* number of limbs of square,
++ 2*bn or 2*bn-1 */
+
+ if (MPFR_UNLIKELY(bn > MPFR_SQR_THRESHOLD))
+ return mpfr_mul (a, b, b, rnd_mode);
+diff -Naurd mpfr-3.1.0-a/src/stack_interface.c mpfr-3.1.0-b/src/stack_interface.c
+--- mpfr-3.1.0-a/src/stack_interface.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/stack_interface.c 2012-03-08 15:17:03.000000000 +0000
+@@ -26,7 +26,7 @@
+ size_t
+ mpfr_custom_get_size (mpfr_prec_t prec)
+ {
+- return (prec + GMP_NUMB_BITS -1) / GMP_NUMB_BITS * BYTES_PER_MP_LIMB;
++ return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB;
+ }
+
+ #undef mpfr_custom_init
+diff -Naurd mpfr-3.1.0-a/src/strtofr.c mpfr-3.1.0-b/src/strtofr.c
+--- mpfr-3.1.0-a/src/strtofr.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/strtofr.c 2012-03-08 15:17:03.000000000 +0000
+@@ -467,7 +467,7 @@
+ /* Set y to the value of the ~prec most significant bits of pstr->mant
+ (as long as we guarantee correct rounding, we don't need to get
+ exactly prec bits). */
+- ysize = (prec - 1) / GMP_NUMB_BITS + 1;
++ ysize = MPFR_PREC2LIMBS (prec);
+ /* prec bits corresponds to ysize limbs */
+ ysize_bits = ysize * GMP_NUMB_BITS;
+ /* and to ysize_bits >= prec > MPFR_PREC (x) bits */
+diff -Naurd mpfr-3.1.0-a/src/sub1sp.c mpfr-3.1.0-b/src/sub1sp.c
+--- mpfr-3.1.0-a/src/sub1sp.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/sub1sp.c 2012-03-08 15:17:03.000000000 +0000
+@@ -155,8 +155,8 @@
+ MPFR_ASSERTD(MPFR_IS_PURE_FP(c));
+
+ /* Read prec and num of limbs */
+- p = MPFR_PREC(b);
+- n = (p-1)/GMP_NUMB_BITS+1;
++ p = MPFR_PREC (b);
++ n = MPFR_PREC2LIMBS (p);
+
+ /* Fast cmp of |b| and |c|*/
+ bx = MPFR_GET_EXP (b);
+diff -Naurd mpfr-3.1.0-a/src/urandomb.c mpfr-3.1.0-b/src/urandomb.c
+--- mpfr-3.1.0-a/src/urandomb.c 2011-10-03 08:17:09.000000000 +0000
++++ mpfr-3.1.0-b/src/urandomb.c 2012-03-08 15:17:03.000000000 +0000
+@@ -31,13 +31,20 @@
+ a sufficient number of limbs */
+ void
+ mpfr_rand_raw (mpfr_limb_ptr mp, gmp_randstate_t rstate,
+- unsigned long int nbits)
++ mpfr_prec_t nbits)
+ {
+ mpz_t z;
+
++ MPFR_ASSERTN (nbits >= 1);
+ /* To be sure to avoid the potential allocation of mpz_urandomb */
+- ALLOC(z) = SIZ(z) = ((nbits - 1) / GMP_NUMB_BITS) + 1;
++ ALLOC(z) = SIZ(z) = MPFR_PREC2LIMBS (nbits);
+ PTR(z) = mp;
++#if __MPFR_GMP(5,0,0)
++ /* Check for integer overflow (unless mp_bitcnt_t is signed,
++ but according to the GMP manual, this shouldn't happen).
++ Note: mp_bitcnt_t has been introduced in GMP 5.0.0. */
++ MPFR_ASSERTN ((mp_bitcnt_t) -1 < 0 || nbits <= (mp_bitcnt_t) -1);
++#endif
+ mpz_urandomb (z, rstate, nbits);
+ }
+
+diff -Naurd mpfr-3.1.0-a/src/version.c mpfr-3.1.0-b/src/version.c
+--- mpfr-3.1.0-a/src/version.c 2012-02-24 13:50:05.000000000 +0000
++++ mpfr-3.1.0-b/src/version.c 2012-03-08 15:17:03.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.0-p6";
++ return "3.1.0-p7";
+ }
+diff -Naurd mpfr-3.1.0-a/tests/tinits.c mpfr-3.1.0-b/tests/tinits.c
+--- mpfr-3.1.0-a/tests/tinits.c 2011-10-03 08:17:14.000000000 +0000
++++ mpfr-3.1.0-b/tests/tinits.c 2012-03-08 15:17:03.000000000 +0000
+@@ -1,4 +1,4 @@
+-/* Test file for mpfr_inits, mpfr_inits2 and mpfr_clears.
++/* Test file for mpfr_init2, mpfr_inits, mpfr_inits2 and mpfr_clears.
+
+ Copyright 2003, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+ Contributed by the Arenaire and Caramel projects, INRIA.
+@@ -20,18 +20,43 @@
+ http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc.,
+ 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */
+
++#include <stdlib.h>
++
+ #include "mpfr-test.h"
+
+ int
+ main (void)
+ {
+ mpfr_t a, b, c;
++ long large_prec;
+
+ tests_start_mpfr ();
++
+ mpfr_inits (a, b, c, (mpfr_ptr) 0);
+ mpfr_clears (a, b, c, (mpfr_ptr) 0);
+ mpfr_inits2 (200, a, b, c, (mpfr_ptr) 0);
+ mpfr_clears (a, b, c, (mpfr_ptr) 0);
++
++ /* test for precision 2^31-1, see
++ https://gforge.inria.fr/tracker/index.php?func=detail&aid=13918 */
++ large_prec = 2147483647;
++ if (getenv ("MPFR_CHECK_LARGEMEM") != NULL)
++ {
++ /* We assume that the precision won't be increased internally. */
++ if (large_prec > MPFR_PREC_MAX)
++ large_prec = MPFR_PREC_MAX;
++ mpfr_inits2 (large_prec, a, b, (mpfr_ptr) 0);
++ mpfr_set_ui (a, 17, MPFR_RNDN);
++ mpfr_set (b, a, MPFR_RNDN);
++ if (mpfr_get_ui (a, MPFR_RNDN) != 17)
++ {
++ printf ("Error in mpfr_init2 with precision 2^31-1\n");
++ exit (1);
++ }
++ mpfr_clears (a, b, (mpfr_ptr) 0);
++ }
++
+ tests_end_mpfr ();
++
+ return 0;
+ }
diff --git a/dev-libs/mpfr/files/3.1.1/patch01 b/dev-libs/mpfr/files/3.1.1/patch01
new file mode 100644
index 000000000000..d73a3d7b4fd8
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.1/patch01
@@ -0,0 +1,235 @@
+diff -Naurd mpfr-3.1.1-a/PATCHES mpfr-3.1.1-b/PATCHES
+--- mpfr-3.1.1-a/PATCHES 2012-08-30 09:28:51.000000000 +0000
++++ mpfr-3.1.1-b/PATCHES 2012-08-30 09:28:51.000000000 +0000
+@@ -0,0 +1 @@
++get_decimal64
+diff -Naurd mpfr-3.1.1-a/VERSION mpfr-3.1.1-b/VERSION
+--- mpfr-3.1.1-a/VERSION 2012-07-03 15:01:13.000000000 +0000
++++ mpfr-3.1.1-b/VERSION 2012-08-30 09:28:51.000000000 +0000
+@@ -1 +1 @@
+-3.1.1
++3.1.1-p1
+diff -Naurd mpfr-3.1.1-a/src/get_d64.c mpfr-3.1.1-b/src/get_d64.c
+--- mpfr-3.1.1-a/src/get_d64.c 2012-07-03 15:01:18.000000000 +0000
++++ mpfr-3.1.1-b/src/get_d64.c 2012-08-30 09:28:51.000000000 +0000
+@@ -32,6 +32,10 @@
+
+ #ifdef MPFR_WANT_DECIMAL_FLOATS
+
++#ifndef DEC64_MAX
++# define DEC64_MAX 9.999999999999999E384dd
++#endif
++
+ #ifdef DPD_FORMAT
+ static int T[1000] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 32,
+@@ -142,26 +146,14 @@
+ static _Decimal64
+ get_decimal64_min (int negative)
+ {
+- union ieee_double_extract x;
+-
+- x.s.sig = (negative) ? 1 : 0;
+- x.s.exp = 0;
+- x.s.manh = 0;
+- x.s.manl = 1;
+- return x.d;
++ return negative ? - 1E-398dd : 1E-398dd;
+ }
+
+ /* construct the decimal64 largest finite number with given sign */
+ static _Decimal64
+ get_decimal64_max (int negative)
+ {
+- union ieee_double_extract x;
+-
+- x.s.sig = (negative) ? 1 : 0;
+- x.s.exp = 1919;
+- x.s.manh = 1048575; /* 2^20-1 */
+- x.s.manl = ~0;
+- return x.d;
++ return negative ? - DEC64_MAX : DEC64_MAX;
+ }
+
+ /* one-to-one conversion:
+@@ -334,7 +326,8 @@
+ /* the largest decimal64 number is just below 10^(385) < 2^1279 */
+ else if (MPFR_UNLIKELY (e > 1279)) /* then src >= 2^1279 */
+ {
+- if (MPFR_RNDZ || (rnd_mode == MPFR_RNDU && negative != 0)
++ if (rnd_mode == MPFR_RNDZ
++ || (rnd_mode == MPFR_RNDU && negative != 0)
+ || (rnd_mode == MPFR_RNDD && negative == 0))
+ return get_decimal64_max (negative);
+ else
+@@ -354,6 +347,15 @@
+ which corresponds to s=[0.]1000...000 and e=-397 */
+ if (e < -397)
+ {
++ if (rnd_mode == MPFR_RNDN && e == -398)
++ {
++ /* If 0.5E-398 < |src| < 1E-398 (smallest subnormal),
++ src should round to +/- 1E-398 in MPFR_RNDN. */
++ mpfr_get_str (s, &e, 10, 1, src, MPFR_RNDA);
++ return e == -398 && s[negative] <= '5' ?
++ get_decimal64_zero (negative) :
++ get_decimal64_min (negative);
++ }
+ if (rnd_mode == MPFR_RNDZ || rnd_mode == MPFR_RNDN
+ || (rnd_mode == MPFR_RNDD && negative == 0)
+ || (rnd_mode == MPFR_RNDU && negative != 0))
+@@ -379,7 +381,8 @@
+ which corresponds to s=[0.]9999...999 and e=385 */
+ else if (e > 385)
+ {
+- if (MPFR_RNDZ || (rnd_mode == MPFR_RNDU && negative != 0)
++ if (rnd_mode == MPFR_RNDZ
++ || (rnd_mode == MPFR_RNDU && negative != 0)
+ || (rnd_mode == MPFR_RNDD && negative == 0))
+ return get_decimal64_max (negative);
+ else
+diff -Naurd mpfr-3.1.1-a/src/mpfr.h mpfr-3.1.1-b/src/mpfr.h
+--- mpfr-3.1.1-a/src/mpfr.h 2012-07-03 15:01:19.000000000 +0000
++++ mpfr-3.1.1-b/src/mpfr.h 2012-08-30 09:28:51.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.1.1"
++#define MPFR_VERSION_STRING "3.1.1-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.1-a/src/version.c mpfr-3.1.1-b/src/version.c
+--- mpfr-3.1.1-a/src/version.c 2012-07-03 15:01:18.000000000 +0000
++++ mpfr-3.1.1-b/src/version.c 2012-08-30 09:28:51.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.1";
++ return "3.1.1-p1";
+ }
+diff -Naurd mpfr-3.1.1-a/tests/tget_set_d64.c mpfr-3.1.1-b/tests/tget_set_d64.c
+--- mpfr-3.1.1-a/tests/tget_set_d64.c 2012-07-03 15:01:24.000000000 +0000
++++ mpfr-3.1.1-b/tests/tget_set_d64.c 2012-08-30 09:28:51.000000000 +0000
+@@ -25,6 +25,10 @@
+ #include <stdlib.h> /* for exit */
+ #include "mpfr-test.h"
+
++#ifndef DEC64_MAX
++# define DEC64_MAX 9.999999999999999E384dd
++#endif
++
+ /* #define DEBUG */
+
+ static void
+@@ -149,6 +153,15 @@
+ mpfr_set_str (x, "9.999999999999999E384", 10, MPFR_RNDZ);
+ mpfr_set (y, x, MPFR_RNDZ);
+ d = mpfr_get_decimal64 (x, MPFR_RNDU);
++ ASSERT_ALWAYS (d == DEC64_MAX);
++ mpfr_set_ui (x, 0, MPFR_RNDZ);
++ mpfr_set_decimal64 (x, d, MPFR_RNDZ);
++ ASSERT_ALWAYS (mpfr_cmp (x, y) == 0);
++
++ mpfr_set_str (x, "-9.999999999999999E384", 10, MPFR_RNDZ);
++ mpfr_set (y, x, MPFR_RNDZ);
++ d = mpfr_get_decimal64 (x, MPFR_RNDA);
++ ASSERT_ALWAYS (d == -DEC64_MAX);
+ mpfr_set_ui (x, 0, MPFR_RNDZ);
+ mpfr_set_decimal64 (x, d, MPFR_RNDZ);
+ ASSERT_ALWAYS (mpfr_cmp (x, y) == 0);
+@@ -225,6 +238,83 @@
+ mpfr_clear (x);
+ }
+
++static void
++check_overflow (void)
++{
++ mpfr_t x;
++ int err = 0, neg, rnd;
++
++ mpfr_init2 (x, 96);
++ for (neg = 0; neg < 2; neg++)
++ RND_LOOP (rnd)
++ {
++ _Decimal64 d, e;
++ mpfr_rnd_t r = (mpfr_rnd_t) rnd;
++ int sign = neg ? -1 : 1;
++
++ e = sign * (MPFR_IS_LIKE_RNDZ (r, neg) ? 1 : 2) * DEC64_MAX;
++ /* This tests the binary exponent e > 1279 case of get_d64.c */
++ mpfr_set_si_2exp (x, sign, 9999, MPFR_RNDN);
++ d = mpfr_get_decimal64 (x, r);
++ if (d != e)
++ {
++ printf ("Error 1 in check_overflow for %s, %s\n",
++ neg ? "negative" : "positive",
++ mpfr_print_rnd_mode (r));
++ err = 1;
++ }
++ /* This tests the decimal exponent e > 385 case of get_d64.c */
++ mpfr_set_si_2exp (x, sign * 31, 1274, MPFR_RNDN);
++ d = mpfr_get_decimal64 (x, r);
++ if (d != e)
++ {
++ printf ("Error 2 in check_overflow for %s, %s\n",
++ neg ? "negative" : "positive",
++ mpfr_print_rnd_mode (r));
++ err = 1;
++ }
++ /* This tests the last else (-382 <= e <= 385) of get_d64.c */
++ mpfr_set_decimal64 (x, e, MPFR_RNDA);
++ d = mpfr_get_decimal64 (x, r);
++ if (d != e)
++ {
++ printf ("Error 3 in check_overflow for %s, %s\n",
++ neg ? "negative" : "positive",
++ mpfr_print_rnd_mode (r));
++ err = 1;
++ }
++ }
++ mpfr_clear (x);
++ if (err)
++ exit (1);
++}
++
++static void
++check_tiny (void)
++{
++ mpfr_t x;
++ _Decimal64 d;
++
++ /* If 0.5E-398 < |x| < 1E-398 (smallest subnormal), x should round
++ to +/- 1E-398 in MPFR_RNDN. Note: the midpoint 0.5E-398 between
++ 0 and 1E-398 is not a representable binary number, so that there
++ are no tests for it. */
++ mpfr_init2 (x, 128);
++ mpfr_set_str (x, "1E-398", 10, MPFR_RNDZ);
++ d = mpfr_get_decimal64 (x, MPFR_RNDN);
++ MPFR_ASSERTN (d == 1.0E-398dd);
++ mpfr_neg (x, x, MPFR_RNDN);
++ d = mpfr_get_decimal64 (x, MPFR_RNDN);
++ MPFR_ASSERTN (d == -1.0E-398dd);
++ mpfr_set_str (x, "0.5E-398", 10, MPFR_RNDU);
++ d = mpfr_get_decimal64 (x, MPFR_RNDN);
++ MPFR_ASSERTN (d == 1.0E-398dd);
++ mpfr_neg (x, x, MPFR_RNDN);
++ d = mpfr_get_decimal64 (x, MPFR_RNDN);
++ MPFR_ASSERTN (d == -1.0E-398dd);
++ mpfr_clear (x);
++}
++
+ int
+ main (void)
+ {
+@@ -241,6 +331,8 @@
+ check_inf_nan ();
+ check_random ();
+ check_native ();
++ check_overflow ();
++ check_tiny ();
+
+ tests_end_mpfr ();
+ return 0;
diff --git a/dev-libs/mpfr/files/3.1.1/patch02 b/dev-libs/mpfr/files/3.1.1/patch02
new file mode 100644
index 000000000000..76dbc4534d25
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.1/patch02
@@ -0,0 +1,170 @@
+diff -Naurd mpfr-3.1.1-a/PATCHES mpfr-3.1.1-b/PATCHES
+--- mpfr-3.1.1-a/PATCHES 2012-08-30 09:35:12.000000000 +0000
++++ mpfr-3.1.1-b/PATCHES 2012-08-30 09:35:12.000000000 +0000
+@@ -0,0 +1 @@
++strtofr-ternary-value
+diff -Naurd mpfr-3.1.1-a/VERSION mpfr-3.1.1-b/VERSION
+--- mpfr-3.1.1-a/VERSION 2012-08-30 09:28:51.000000000 +0000
++++ mpfr-3.1.1-b/VERSION 2012-08-30 09:35:12.000000000 +0000
+@@ -1 +1 @@
+-3.1.1-p1
++3.1.1-p2
+diff -Naurd mpfr-3.1.1-a/src/mpfr.h mpfr-3.1.1-b/src/mpfr.h
+--- mpfr-3.1.1-a/src/mpfr.h 2012-08-30 09:28:51.000000000 +0000
++++ mpfr-3.1.1-b/src/mpfr.h 2012-08-30 09:35:12.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 1
+-#define MPFR_VERSION_STRING "3.1.1-p1"
++#define MPFR_VERSION_STRING "3.1.1-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.1-a/src/strtofr.c mpfr-3.1.1-b/src/strtofr.c
+--- mpfr-3.1.1-a/src/strtofr.c 2012-07-03 15:01:16.000000000 +0000
++++ mpfr-3.1.1-b/src/strtofr.c 2012-08-30 09:35:12.000000000 +0000
+@@ -667,6 +667,20 @@
+ /* (z, exp_z) = base^(exp_base-pstr_size) */
+ z = result + 2*ysize + 1;
+ err = mpfr_mpn_exp (z, &exp_z, pstr->base, exp_z, ysize);
++ /* Since we want y/z rounded toward zero, we must get an upper
++ bound of z. If err >= 0, the error on z is bounded by 2^err. */
++ if (err >= 0)
++ {
++ mp_limb_t cy;
++ unsigned long h = err / GMP_NUMB_BITS;
++ unsigned long l = err - h * GMP_NUMB_BITS;
++
++ if (h >= ysize) /* not enough precision in z */
++ goto next_loop;
++ cy = mpn_add_1 (z, z, ysize - h, MPFR_LIMB_ONE << l);
++ if (cy != 0) /* the code below requires z on ysize limbs */
++ goto next_loop;
++ }
+ exact = exact && (err == -1);
+ if (err == -2)
+ goto underflow; /* FIXME: Sure? */
+@@ -730,6 +744,7 @@
+ MPFR_RNDN, rnd, MPFR_PREC(x)))
+ break;
+
++ next_loop:
+ /* update the prec for next loop */
+ MPFR_ZIV_NEXT (loop, prec);
+ } /* loop */
+diff -Naurd mpfr-3.1.1-a/src/version.c mpfr-3.1.1-b/src/version.c
+--- mpfr-3.1.1-a/src/version.c 2012-08-30 09:28:51.000000000 +0000
++++ mpfr-3.1.1-b/src/version.c 2012-08-30 09:35:12.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.1-p1";
++ return "3.1.1-p2";
+ }
+diff -Naurd mpfr-3.1.1-a/tests/tstrtofr.c mpfr-3.1.1-b/tests/tstrtofr.c
+--- mpfr-3.1.1-a/tests/tstrtofr.c 2012-07-03 15:01:24.000000000 +0000
++++ mpfr-3.1.1-b/tests/tstrtofr.c 2012-08-30 09:35:12.000000000 +0000
+@@ -1105,6 +1105,92 @@
+ mpfr_clear (y);
+ }
+
++/* From a bug reported by Joseph S. Myers
++ https://sympa.inria.fr/sympa/arc/mpfr/2012-08/msg00005.html */
++static void
++bug20120814 (void)
++{
++ mpfr_exp_t emin = -30, e;
++ mpfr_t x, y;
++ int r;
++ char s[64], *p;
++
++ mpfr_init2 (x, 2);
++ mpfr_set_ui_2exp (x, 3, emin - 2, MPFR_RNDN);
++ mpfr_get_str (s + 1, &e, 10, 19, x, MPFR_RNDD);
++ s[0] = s[1];
++ s[1] = '.';
++ for (p = s; *p != 0; p++) ;
++ *p = 'e';
++ sprintf (p + 1, "%d", (int) e - 1);
++
++ mpfr_init2 (y, 4);
++ r = mpfr_strtofr (y, s, NULL, 0, MPFR_RNDN);
++ if (r <= 0 || ! mpfr_equal_p (x, y))
++ {
++ printf ("Error in bug20120814\n");
++ printf ("mpfr_strtofr failed on string \"%s\"\n", s);
++ printf ("Expected inex > 0 and y = 0.1100E%d\n", (int) emin);
++ printf ("Got inex = %-6d and y = ", r);
++ mpfr_dump (y);
++ exit (1);
++ }
++
++ mpfr_clear (x);
++ mpfr_clear (y);
++}
++
++static void
++bug20120829 (void)
++{
++ mpfr_t x1, x2, e;
++ int inex1, inex2, i, r;
++ char s[48] = "1e-1";
++
++ mpfr_init2 (e, 128);
++ mpfr_inits2 (4, x1, x2, (mpfr_ptr) 0);
++
++ inex1 = mpfr_set_si (e, -1, MPFR_RNDN);
++ MPFR_ASSERTN (inex1 == 0);
++
++ for (i = 1; i <= sizeof(s) - 5; i++)
++ {
++ s[3+i] = '0';
++ s[4+i] = 0;
++ inex1 = mpfr_mul_ui (e, e, 10, MPFR_RNDN);
++ MPFR_ASSERTN (inex1 == 0);
++ RND_LOOP(r)
++ {
++ mpfr_rnd_t rnd = (mpfr_rnd_t) r;
++
++ inex1 = mpfr_exp10 (x1, e, rnd);
++ inex1 = SIGN (inex1);
++ inex2 = mpfr_strtofr (x2, s, NULL, 0, rnd);
++ inex2 = SIGN (inex2);
++ /* On 32-bit machines, for i = 7, r8389, r8391 and r8394 do:
++ strtofr.c:...: MPFR assertion failed: cy == 0
++ r8396 is OK.
++ On 64-bit machines, for i = 15,
++ r8389 does: strtofr.c:678: MPFR assertion failed: err < (64 - 0)
++ r8391 does: strtofr.c:680: MPFR assertion failed: h < ysize
++ r8394 and r8396 are OK.
++ */
++ if (! mpfr_equal_p (x1, x2) || inex1 != inex2)
++ {
++ printf ("Error in bug20120829 for i = %d, rnd = %s\n",
++ i, mpfr_print_rnd_mode (rnd));
++ printf ("Expected inex = %d, x = ", inex1);
++ mpfr_dump (x1);
++ printf ("Got inex = %d, x = ", inex2);
++ mpfr_dump (x2);
++ exit (1);
++ }
++ }
++ }
++
++ mpfr_clears (e, x1, x2, (mpfr_ptr) 0);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -1117,6 +1203,8 @@
+ check_retval ();
+ bug20081028 ();
+ test20100310 ();
++ bug20120814 ();
++ bug20120829 ();
+
+ tests_end_mpfr ();
+ return 0;
diff --git a/dev-libs/mpfr/files/3.1.2/patch01 b/dev-libs/mpfr/files/3.1.2/patch01
new file mode 100644
index 000000000000..731ea92f4395
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch01
@@ -0,0 +1,45 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/PATCHES 2013-09-26 10:52:52.000000000 +0000
+@@ -0,0 +1 @@
++exp_2
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2013-03-13 15:37:28.000000000 +0000
++++ mpfr-3.1.2-b/VERSION 2013-09-26 10:52:52.000000000 +0000
+@@ -1 +1 @@
+-3.1.2
++3.1.2-p1
+diff -Naurd mpfr-3.1.2-a/src/exp_2.c mpfr-3.1.2-b/src/exp_2.c
+--- mpfr-3.1.2-a/src/exp_2.c 2013-03-13 15:37:28.000000000 +0000
++++ mpfr-3.1.2-b/src/exp_2.c 2013-09-26 10:52:52.000000000 +0000
+@@ -204,7 +204,7 @@
+ for (k = 0; k < K; k++)
+ {
+ mpz_mul (ss, ss, ss);
+- exps <<= 1;
++ exps *= 2;
+ exps += mpz_normalize (ss, ss, q);
+ }
+ mpfr_set_z (s, ss, MPFR_RNDN);
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2013-03-13 15:37:37.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2"
++#define MPFR_VERSION_STRING "3.1.2-p1"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2013-03-13 15:37:34.000000000 +0000
++++ mpfr-3.1.2-b/src/version.c 2013-09-26 10:52:52.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2";
++ return "3.1.2-p1";
+ }
diff --git a/dev-libs/mpfr/files/3.1.2/patch02 b/dev-libs/mpfr/files/3.1.2/patch02
new file mode 100644
index 000000000000..b229c18d093c
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch02
@@ -0,0 +1,605 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2013-09-26 10:56:55.000000000 +0000
++++ mpfr-3.1.2-b/PATCHES 2013-09-26 10:56:55.000000000 +0000
+@@ -0,0 +1 @@
++fits-smallneg
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/VERSION 2013-09-26 10:56:55.000000000 +0000
+@@ -1 +1 @@
+-3.1.2-p1
++3.1.2-p2
+diff -Naurd mpfr-3.1.2-a/src/fits_u.h mpfr-3.1.2-b/src/fits_u.h
+--- mpfr-3.1.2-a/src/fits_u.h 2013-03-13 15:37:35.000000000 +0000
++++ mpfr-3.1.2-b/src/fits_u.h 2013-09-26 10:56:55.000000000 +0000
+@@ -32,17 +32,20 @@
+ int res;
+
+ if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
+- /* Zero always fit */
+- return MPFR_IS_ZERO (f) ? 1 : 0;
+- else if (MPFR_IS_NEG (f))
+- /* Negative numbers don't fit */
+- return 0;
+- /* now it fits if
+- (a) f <= MAXIMUM
+- (b) round(f, prec(slong), rnd) <= MAXIMUM */
++ return MPFR_IS_ZERO (f) ? 1 : 0; /* Zero always fits */
+
+ e = MPFR_GET_EXP (f);
+
++ if (MPFR_IS_NEG (f))
++ return e >= 1 ? 0 /* f <= -1 does not fit */
++ : rnd != MPFR_RNDN ? MPFR_IS_LIKE_RNDU (rnd, -1) /* directed mode */
++ : e < 0 ? 1 /* f > -1/2 fits in MPFR_RNDN */
++ : mpfr_powerof2_raw(f); /* -1/2 fits, -1 < f < -1/2 don't */
++
++ /* Now it fits if
++ (a) f <= MAXIMUM
++ (b) round(f, prec(slong), rnd) <= MAXIMUM */
++
+ /* first compute prec(MAXIMUM); fits in an int */
+ for (s = MAXIMUM, prec = 0; s != 0; s /= 2, prec ++);
+
+diff -Naurd mpfr-3.1.2-a/src/fits_uintmax.c mpfr-3.1.2-b/src/fits_uintmax.c
+--- mpfr-3.1.2-a/src/fits_uintmax.c 2013-03-13 15:37:33.000000000 +0000
++++ mpfr-3.1.2-b/src/fits_uintmax.c 2013-09-26 10:56:55.000000000 +0000
+@@ -27,51 +27,19 @@
+ #include "mpfr-intmax.h"
+ #include "mpfr-impl.h"
+
+-#ifdef _MPFR_H_HAVE_INTMAX_T
+-
+-/* We can't use fits_u.h <= mpfr_cmp_ui */
+-int
+-mpfr_fits_uintmax_p (mpfr_srcptr f, mpfr_rnd_t rnd)
+-{
+- mpfr_exp_t e;
+- int prec;
+- uintmax_t s;
+- mpfr_t x;
+- int res;
+-
+- if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
+- /* Zero always fit */
+- return MPFR_IS_ZERO (f) ? 1 : 0;
+- else if (MPFR_IS_NEG (f))
+- /* Negative numbers don't fit */
+- return 0;
+- /* now it fits if
+- (a) f <= MAXIMUM
+- (b) round(f, prec(slong), rnd) <= MAXIMUM */
+-
+- e = MPFR_GET_EXP (f);
+-
+- /* first compute prec(MAXIMUM); fits in an int */
+- for (s = MPFR_UINTMAX_MAX, prec = 0; s != 0; s /= 2, prec ++);
+-
+- /* MAXIMUM needs prec bits, i.e. MAXIMUM = 2^prec - 1 */
+-
+- /* if e <= prec - 1, then f < 2^(prec-1) < MAXIMUM */
+- if (e <= prec - 1)
+- return 1;
++/* Note: though mpfr-impl.h is included in fits_u.h, we also include it
++ above so that it gets included even when _MPFR_H_HAVE_INTMAX_T is not
++ defined; this is necessary to avoid an empty translation unit, which
++ is forbidden by ISO C. Without this, a failing test can be reproduced
++ by creating an invalid stdint.h somewhere in the default include path
++ and by compiling MPFR with "gcc -ansi -pedantic-errors". */
+
+- /* if e >= prec + 1, then f >= 2^prec > MAXIMUM */
+- if (e >= prec + 1)
+- return 0;
++#ifdef _MPFR_H_HAVE_INTMAX_T
+
+- MPFR_ASSERTD (e == prec);
++#define FUNCTION mpfr_fits_uintmax_p
++#define MAXIMUM MPFR_UINTMAX_MAX
++#define TYPE uintmax_t
+
+- /* hard case: first round to prec bits, then check */
+- mpfr_init2 (x, prec);
+- mpfr_set (x, f, rnd);
+- res = MPFR_GET_EXP (x) == e;
+- mpfr_clear (x);
+- return res;
+-}
++#include "fits_u.h"
+
+ #endif
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2013-09-26 10:56:55.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p1"
++#define MPFR_VERSION_STRING "3.1.2-p2"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/src/version.c 2013-09-26 10:56:55.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p1";
++ return "3.1.2-p2";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/tfits.c mpfr-3.1.2-b/tests/tfits.c
+--- mpfr-3.1.2-a/tests/tfits.c 2013-03-13 15:37:45.000000000 +0000
++++ mpfr-3.1.2-b/tests/tfits.c 2013-09-26 10:56:55.000000000 +0000
+@@ -33,155 +33,176 @@
+ #include "mpfr-intmax.h"
+ #include "mpfr-test.h"
+
+-#define ERROR1 { printf("Initial error for x="); mpfr_dump(x); exit(1); }
+-#define ERROR2 { printf("Error for x="); mpfr_dump(x); exit(1); }
++#define ERROR1(N) \
++ do \
++ { \
++ printf("Error %d for rnd = %s and x = ", N, \
++ mpfr_print_rnd_mode ((mpfr_rnd_t) r)); \
++ mpfr_dump(x); \
++ exit(1); \
++ } \
++ while (0)
+
+ static void check_intmax (void);
+
+ int
+ main (void)
+ {
+- mpfr_t x;
++ mpfr_t x, y;
++ int i, r;
+
+ tests_start_mpfr ();
+
+ mpfr_init2 (x, 256);
++ mpfr_init2 (y, 8);
+
+- /* Check NAN */
+- mpfr_set_nan (x);
+- if (mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR1;
++ RND_LOOP (r)
++ {
+
+- /* Check INF */
+- mpfr_set_inf (x, 1);
+- if (mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check NAN */
++ mpfr_set_nan (x);
++ if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (1);
++ if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (2);
++ if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (3);
++ if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (4);
++ if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (5);
++ if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (6);
+
+- /* Check Zero */
+- MPFR_SET_ZERO (x);
+- if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check INF */
++ mpfr_set_inf (x, 1);
++ if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (7);
++ if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (8);
++ if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (9);
++ if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (10);
++ if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (11);
++ if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (12);
+
+- /* Check small op */
+- mpfr_set_str1 (x, "1@-1");
+- if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check Zero */
++ MPFR_SET_ZERO (x);
++ if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (13);
++ if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (14);
++ if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (15);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (16);
++ if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (17);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (18);
+
+- /* Check 17 */
+- mpfr_set_ui (x, 17, MPFR_RNDN);
+- if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check small positive op */
++ mpfr_set_str1 (x, "1@-1");
++ if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (19);
++ if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (20);
++ if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (21);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (22);
++ if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (23);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (24);
+
+- /* Check all other values */
+- mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
+- mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
+- if (mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR1;
+- mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
+- if (mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check 17 */
++ mpfr_set_ui (x, 17, MPFR_RNDN);
++ if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (25);
++ if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (26);
++ if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (27);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (28);
++ if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (29);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (30);
+
+- mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
+- if (!mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
+- if (!mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
+- if (!mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
+- if (!mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check all other values */
++ mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
++ mpfr_mul_2exp (x, x, 1, MPFR_RNDN);
++ if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (31);
++ if (mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (32);
++ mpfr_mul_2exp (x, x, 40, MPFR_RNDN);
++ if (mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (33);
++ if (mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (34);
++ if (mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (35);
++ if (mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (36);
++ if (mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (37);
+
+- mpfr_set_si (x, 1, MPFR_RNDN);
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
++ mpfr_set_ui (x, ULONG_MAX, MPFR_RNDN);
++ if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (38);
++ mpfr_set_ui (x, LONG_MAX, MPFR_RNDN);
++ if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (39);
++ mpfr_set_ui (x, UINT_MAX, MPFR_RNDN);
++ if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (40);
++ mpfr_set_ui (x, INT_MAX, MPFR_RNDN);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (41);
++ mpfr_set_ui (x, USHRT_MAX, MPFR_RNDN);
++ if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (42);
++ mpfr_set_ui (x, SHRT_MAX, MPFR_RNDN);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (43);
+
+- /* Check negative value */
+- mpfr_set_si (x, -1, MPFR_RNDN);
+- if (!mpfr_fits_sint_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_sshort_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_slong_p (x, MPFR_RNDN))
+- ERROR2;
+- if (mpfr_fits_uint_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_ushort_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_ulong_p (x, MPFR_RNDN))
+- ERROR1;
++ mpfr_set_si (x, 1, MPFR_RNDN);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (44);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (45);
++
++ /* Check negative op */
++ for (i = 1; i <= 4; i++)
++ {
++ int inv;
++
++ mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
++ mpfr_rint (y, x, (mpfr_rnd_t) r);
++ inv = MPFR_NOTZERO (y);
++ if (!mpfr_fits_ulong_p (x, (mpfr_rnd_t) r) ^ inv)
++ ERROR1 (46);
++ if (!mpfr_fits_slong_p (x, (mpfr_rnd_t) r))
++ ERROR1 (47);
++ if (!mpfr_fits_uint_p (x, (mpfr_rnd_t) r) ^ inv)
++ ERROR1 (48);
++ if (!mpfr_fits_sint_p (x, (mpfr_rnd_t) r))
++ ERROR1 (49);
++ if (!mpfr_fits_ushort_p (x, (mpfr_rnd_t) r) ^ inv)
++ ERROR1 (50);
++ if (!mpfr_fits_sshort_p (x, (mpfr_rnd_t) r))
++ ERROR1 (51);
++ }
++ }
+
+ mpfr_clear (x);
++ mpfr_clear (y);
+
+ check_intmax ();
+
+@@ -189,85 +210,98 @@
+ return 0;
+ }
+
+-static void check_intmax (void)
++static void
++check_intmax (void)
+ {
+ #ifdef _MPFR_H_HAVE_INTMAX_T
+- mpfr_t x;
++ mpfr_t x, y;
++ int i, r;
+
+- mpfr_init2 (x, sizeof (uintmax_t)*CHAR_BIT);
++ mpfr_init2 (x, sizeof (uintmax_t) * CHAR_BIT);
++ mpfr_init2 (y, 8);
+
+- /* Check NAN */
+- mpfr_set_nan (x);
+- if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR1;
++ RND_LOOP (r)
++ {
++ /* Check NAN */
++ mpfr_set_nan (x);
++ if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (52);
++ if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (53);
+
+- /* Check INF */
+- mpfr_set_inf (x, 1);
+- if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check INF */
++ mpfr_set_inf (x, 1);
++ if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (54);
++ if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (55);
+
+- /* Check Zero */
+- MPFR_SET_ZERO (x);
+- if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check Zero */
++ MPFR_SET_ZERO (x);
++ if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (56);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (57);
+
+- /* Check small op */
+- mpfr_set_str1 (x, "1@-1");
+- if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check positive small op */
++ mpfr_set_str1 (x, "1@-1");
++ if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (58);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (59);
+
+- /* Check 17 */
+- mpfr_set_ui (x, 17, MPFR_RNDN);
+- if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR2;
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
++ /* Check 17 */
++ mpfr_set_ui (x, 17, MPFR_RNDN);
++ if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (60);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (61);
+
+- /* Check hugest */
+- mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
+- if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR1;
+- if (mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check hugest */
++ mpfr_set_ui_2exp (x, 42, sizeof (uintmax_t) * 32, MPFR_RNDN);
++ if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (62);
++ if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (63);
+
+- /* Check all other values */
+- mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
+- mpfr_add_ui (x, x, 1, MPFR_RNDN);
+- if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR1;
+- mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
+- if (!mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
+- mpfr_add_ui (x, x, 1, MPFR_RNDN);
+- if (mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR1;
+- mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
+- mpfr_sub_ui (x, x, 1, MPFR_RNDN);
+- if (mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check all other values */
++ mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
++ mpfr_add_ui (x, x, 1, MPFR_RNDN);
++ if (mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (64);
++ mpfr_set_uj (x, MPFR_UINTMAX_MAX, MPFR_RNDN);
++ if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (65);
++ mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
++ mpfr_add_ui (x, x, 1, MPFR_RNDN);
++ if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (66);
++ mpfr_set_sj (x, MPFR_INTMAX_MAX, MPFR_RNDN);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (67);
++ mpfr_set_sj (x, MPFR_INTMAX_MIN, MPFR_RNDN);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (68);
++ mpfr_sub_ui (x, x, 1, MPFR_RNDN);
++ if (mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (69);
+
+- /* Check negative value */
+- mpfr_set_si (x, -1, MPFR_RNDN);
+- if (!mpfr_fits_intmax_p (x, MPFR_RNDN))
+- ERROR2;
+- if (mpfr_fits_uintmax_p (x, MPFR_RNDN))
+- ERROR1;
++ /* Check negative op */
++ for (i = 1; i <= 4; i++)
++ {
++ int inv;
++
++ mpfr_set_si_2exp (x, -i, -2, MPFR_RNDN);
++ mpfr_rint (y, x, (mpfr_rnd_t) r);
++ inv = MPFR_NOTZERO (y);
++ if (!mpfr_fits_uintmax_p (x, (mpfr_rnd_t) r) ^ inv)
++ ERROR1 (70);
++ if (!mpfr_fits_intmax_p (x, (mpfr_rnd_t) r))
++ ERROR1 (71);
++ }
++ }
+
+ mpfr_clear (x);
++ mpfr_clear (y);
+ #endif
+ }
+-
diff --git a/dev-libs/mpfr/files/3.1.2/patch03 b/dev-libs/mpfr/files/3.1.2/patch03
new file mode 100644
index 000000000000..8e0cd8e04b7e
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch03
@@ -0,0 +1,129 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2013-10-09 13:34:21.000000000 +0000
++++ mpfr-3.1.2-b/PATCHES 2013-10-09 13:34:21.000000000 +0000
+@@ -0,0 +1 @@
++clang-divby0
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/VERSION 2013-10-09 13:34:21.000000000 +0000
+@@ -1 +1 @@
+-3.1.2-p2
++3.1.2-p3
+diff -Naurd mpfr-3.1.2-a/src/mpfr-impl.h mpfr-3.1.2-b/src/mpfr-impl.h
+--- mpfr-3.1.2-a/src/mpfr-impl.h 2013-03-13 15:37:36.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr-impl.h 2013-10-09 13:34:21.000000000 +0000
+@@ -468,8 +468,16 @@
+ #define MPFR_LIMBS_PER_FLT ((IEEE_FLT_MANT_DIG-1)/GMP_NUMB_BITS+1)
+
+ /* Visual C++ doesn't support +1.0/0.0, -1.0/0.0 and 0.0/0.0
+- at compile time. */
+-#if defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)
++ at compile time.
++ Clang with -fsanitize=undefined is a bit similar due to a bug:
++ http://llvm.org/bugs/show_bug.cgi?id=17381
++ but even without its sanitizer, it may be better to use the
++ double_zero version until IEEE 754 division by zero is properly
++ supported:
++ http://llvm.org/bugs/show_bug.cgi?id=17000
++*/
++#if (defined(_MSC_VER) && defined(_WIN32) && (_MSC_VER >= 1200)) || \
++ defined(__clang__)
+ static double double_zero = 0.0;
+ # define DBL_NAN (double_zero/double_zero)
+ # define DBL_POS_INF ((double) 1.0/double_zero)
+@@ -501,6 +509,8 @@
+ (with Xcode 2.4.1, i.e. the latest one). */
+ #define LVALUE(x) (&(x) == &(x) || &(x) != &(x))
+ #define DOUBLE_ISINF(x) (LVALUE(x) && ((x) > DBL_MAX || (x) < -DBL_MAX))
++/* The DOUBLE_ISNAN(x) macro is also valid on long double x
++ (assuming that the compiler isn't too broken). */
+ #ifdef MPFR_NANISNAN
+ /* Avoid MIPSpro / IRIX64 / gcc -ffast-math (incorrect) optimizations.
+ The + must not be replaced by a ||. With gcc -ffast-math, NaN is
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2013-10-09 13:34:21.000000000 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p2"
++#define MPFR_VERSION_STRING "3.1.2-p3"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2013-09-26 10:52:52.000000000 +0000
++++ mpfr-3.1.2-b/src/version.c 2013-10-09 13:34:21.000000000 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p2";
++ return "3.1.2-p3";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/tget_flt.c mpfr-3.1.2-b/tests/tget_flt.c
+--- mpfr-3.1.2-a/tests/tget_flt.c 2013-03-13 15:37:44.000000000 +0000
++++ mpfr-3.1.2-b/tests/tget_flt.c 2013-10-09 13:34:21.000000000 +0000
+@@ -28,9 +28,17 @@
+ main (void)
+ {
+ mpfr_t x, y;
+- float f, g, infp;
++ float f, g;
+ int i;
++#if !defined(MPFR_ERRDIVZERO)
++ float infp;
++#endif
++
++ tests_start_mpfr ();
+
++#if !defined(MPFR_ERRDIVZERO)
++ /* The definition of DBL_POS_INF involves a division by 0. This makes
++ "clang -O2 -fsanitize=undefined -fno-sanitize-recover" fail. */
+ infp = (float) DBL_POS_INF;
+ if (infp * 0.5 != infp)
+ {
+@@ -38,8 +46,7 @@
+ fprintf (stderr, "(this is probably a compiler bug, please report)\n");
+ exit (1);
+ }
+-
+- tests_start_mpfr ();
++#endif
+
+ mpfr_init2 (x, 24);
+ mpfr_init2 (y, 24);
+@@ -353,6 +360,7 @@
+ printf ("expected %.8e, got %.8e\n", g, f);
+ exit (1);
+ }
++#if !defined(MPFR_ERRDIVZERO)
+ f = mpfr_get_flt (x, MPFR_RNDN); /* first round to 2^128 (even rule),
+ thus we should get +Inf */
+ g = infp;
+@@ -376,6 +384,7 @@
+ printf ("expected %.8e, got %.8e\n", g, f);
+ exit (1);
+ }
++#endif
+
+ mpfr_clear (x);
+ mpfr_clear (y);
+diff -Naurd mpfr-3.1.2-a/tests/tset_ld.c mpfr-3.1.2-b/tests/tset_ld.c
+--- mpfr-3.1.2-a/tests/tset_ld.c 2013-03-13 15:37:44.000000000 +0000
++++ mpfr-3.1.2-b/tests/tset_ld.c 2013-10-09 13:34:21.000000000 +0000
+@@ -47,8 +47,11 @@
+ static int
+ Isnan_ld (long double d)
+ {
+- double e = (double) d;
+- if (DOUBLE_ISNAN (e))
++ /* Do not convert d to double as this can give an overflow, which
++ may confuse compilers without IEEE 754 support (such as clang
++ -fsanitize=undefined), or trigger a trap if enabled.
++ The DOUBLE_ISNAN macro should work fine on long double. */
++ if (DOUBLE_ISNAN (d))
+ return 1;
+ LONGDOUBLE_NAN_ACTION (d, goto yes);
+ return 0;
diff --git a/dev-libs/mpfr/files/3.1.2/patch04 b/dev-libs/mpfr/files/3.1.2/patch04
new file mode 100644
index 000000000000..2451f36027e0
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch04
@@ -0,0 +1,84 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2013-11-15 00:51:49.211333830 +0000
++++ mpfr-3.1.2-b/PATCHES 2013-11-15 00:51:49.323334999 +0000
+@@ -0,0 +1 @@
++printf-alt0
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2013-11-15 00:51:49.211333830 +0000
++++ mpfr-3.1.2-b/VERSION 2013-11-15 00:51:49.323334999 +0000
+@@ -1 +1 @@
+-3.1.2-p3
++3.1.2-p4
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2013-11-15 00:51:49.211333830 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2013-11-15 00:51:49.323334999 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p3"
++#define MPFR_VERSION_STRING "3.1.2-p4"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/vasprintf.c mpfr-3.1.2-b/src/vasprintf.c
+--- mpfr-3.1.2-a/src/vasprintf.c 2013-03-13 15:37:37.000000000 +0000
++++ mpfr-3.1.2-b/src/vasprintf.c 2013-11-15 00:51:49.267334408 +0000
+@@ -1040,7 +1040,7 @@
+ }
+
+ /* Determine the different parts of the string representation of the regular
+- number P when SPEC.SPEC is 'e', 'E', 'g', or 'G'.
++ number P when spec.spec is 'e', 'E', 'g', or 'G'.
+ DEC_INFO contains the previously computed exponent and string or is NULL.
+
+ return -1 if some field > INT_MAX */
+@@ -1167,7 +1167,7 @@
+ }
+
+ /* Determine the different parts of the string representation of the regular
+- number P when SPEC.SPEC is 'f', 'F', 'g', or 'G'.
++ number P when spec.spec is 'f', 'F', 'g', or 'G'.
+ DEC_INFO contains the previously computed exponent and string or is NULL.
+
+ return -1 if some field of number_parts is greater than INT_MAX */
+@@ -1559,7 +1559,7 @@
+ /* fractional part */
+ {
+ np->point = MPFR_DECIMAL_POINT;
+- np->fp_trailing_zeros = (spec.spec == 'g' && spec.spec == 'G') ?
++ np->fp_trailing_zeros = (spec.spec == 'g' || spec.spec == 'G') ?
+ spec.prec - 1 : spec.prec;
+ }
+ else if (spec.alt)
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2013-11-15 00:51:49.211333830 +0000
++++ mpfr-3.1.2-b/src/version.c 2013-11-15 00:51:49.323334999 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p3";
++ return "3.1.2-p4";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/tsprintf.c mpfr-3.1.2-b/tests/tsprintf.c
+--- mpfr-3.1.2-a/tests/tsprintf.c 2013-03-13 15:37:44.000000000 +0000
++++ mpfr-3.1.2-b/tests/tsprintf.c 2013-11-15 00:51:49.267334408 +0000
+@@ -456,10 +456,16 @@
+ check_sprintf ("1.999900 ", "%-#10.7RG", x);
+ check_sprintf ("1.9999 ", "%-10.7RG", x);
+ mpfr_set_ui (x, 1, MPFR_RNDN);
++ check_sprintf ("1.", "%#.1Rg", x);
++ check_sprintf ("1. ", "%-#5.1Rg", x);
++ check_sprintf (" 1.0", "%#5.2Rg", x);
+ check_sprintf ("1.00000000000000000000000000000", "%#.30Rg", x);
+ check_sprintf ("1", "%.30Rg", x);
+ mpfr_set_ui (x, 0, MPFR_RNDN);
+- check_sprintf ("0.000000000000000000000000000000", "%#.30Rg", x);
++ check_sprintf ("0.", "%#.1Rg", x);
++ check_sprintf ("0. ", "%-#5.1Rg", x);
++ check_sprintf (" 0.0", "%#5.2Rg", x);
++ check_sprintf ("0.00000000000000000000000000000", "%#.30Rg", x);
+ check_sprintf ("0", "%.30Rg", x);
+
+ /* following tests with precision 53 bits */
diff --git a/dev-libs/mpfr/files/3.1.2/patch05 b/dev-libs/mpfr/files/3.1.2/patch05
new file mode 100644
index 000000000000..669b91d54dac
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch05
@@ -0,0 +1,42 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2013-12-01 11:07:49.575329762 +0000
++++ mpfr-3.1.2-b/PATCHES 2013-12-01 11:07:49.751331625 +0000
+@@ -0,0 +1 @@
++custom_init_set
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2013-12-01 11:07:49.571329714 +0000
++++ mpfr-3.1.2-b/VERSION 2013-12-01 11:07:49.747331585 +0000
+@@ -1 +1 @@
+-3.1.2-p4
++3.1.2-p5
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2013-12-01 11:07:49.571329714 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2013-12-01 11:07:49.747331585 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p4"
++#define MPFR_VERSION_STRING "3.1.2-p5"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+@@ -861,7 +861,7 @@
+ _t = (mpfr_kind_t) _k; \
+ _s = 1; \
+ } else { \
+- _t = (mpfr_kind_t) -k; \
++ _t = (mpfr_kind_t) - _k; \
+ _s = -1; \
+ } \
+ _e = _t == MPFR_REGULAR_KIND ? (e) : \
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2013-12-01 11:07:49.575329762 +0000
++++ mpfr-3.1.2-b/src/version.c 2013-12-01 11:07:49.747331585 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p4";
++ return "3.1.2-p5";
+ }
diff --git a/dev-libs/mpfr/files/3.1.2/patch06 b/dev-libs/mpfr/files/3.1.2/patch06
new file mode 100644
index 000000000000..50cd04d72491
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch06
@@ -0,0 +1,43 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2014-04-15 21:56:49.609057464 +0000
++++ mpfr-3.1.2-b/PATCHES 2014-04-15 21:56:49.697059857 +0000
+@@ -0,0 +1 @@
++li2-return
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2014-04-15 21:56:49.609057464 +0000
++++ mpfr-3.1.2-b/VERSION 2014-04-15 21:56:49.697059857 +0000
+@@ -1 +1 @@
+-3.1.2-p5
++3.1.2-p6
+diff -Naurd mpfr-3.1.2-a/src/li2.c mpfr-3.1.2-b/src/li2.c
+--- mpfr-3.1.2-a/src/li2.c 2013-03-13 15:37:32.000000000 +0000
++++ mpfr-3.1.2-b/src/li2.c 2014-04-15 21:56:49.653058661 +0000
+@@ -630,5 +630,5 @@
+ return mpfr_check_range (y, inexact, rnd_mode);
+ }
+
+- MPFR_ASSERTN (0); /* should never reach this point */
++ MPFR_RET_NEVER_GO_HERE ();
+ }
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 21:56:49.609057464 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 21:56:49.697059857 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p5"
++#define MPFR_VERSION_STRING "3.1.2-p6"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2014-04-15 21:56:49.609057464 +0000
++++ mpfr-3.1.2-b/src/version.c 2014-04-15 21:56:49.697059857 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p5";
++ return "3.1.2-p6";
+ }
diff --git a/dev-libs/mpfr/files/3.1.2/patch07 b/dev-libs/mpfr/files/3.1.2/patch07
new file mode 100644
index 000000000000..378c3bf4fcf0
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch07
@@ -0,0 +1,71 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2014-04-15 22:04:57.090286262 +0000
++++ mpfr-3.1.2-b/PATCHES 2014-04-15 22:04:57.162288198 +0000
+@@ -0,0 +1 @@
++exp3
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2014-04-15 22:04:57.086286154 +0000
++++ mpfr-3.1.2-b/VERSION 2014-04-15 22:04:57.162288198 +0000
+@@ -1 +1 @@
+-3.1.2-p6
++3.1.2-p7
+diff -Naurd mpfr-3.1.2-a/src/exp3.c mpfr-3.1.2-b/src/exp3.c
+--- mpfr-3.1.2-a/src/exp3.c 2013-03-13 15:37:34.000000000 +0000
++++ mpfr-3.1.2-b/src/exp3.c 2014-04-15 22:04:57.126287230 +0000
+@@ -283,7 +283,7 @@
+ }
+ }
+
+- if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDD, MPFR_RNDZ,
++ if (mpfr_can_round (shift_x > 0 ? t : tmp, realprec, MPFR_RNDN, MPFR_RNDZ,
+ MPFR_PREC(y) + (rnd_mode == MPFR_RNDN)))
+ {
+ inexact = mpfr_set (y, shift_x > 0 ? t : tmp, rnd_mode);
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 22:04:57.086286154 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 22:04:57.162288198 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p6"
++#define MPFR_VERSION_STRING "3.1.2-p7"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2014-04-15 22:04:57.090286262 +0000
++++ mpfr-3.1.2-b/src/version.c 2014-04-15 22:04:57.162288198 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p6";
++ return "3.1.2-p7";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/texp.c mpfr-3.1.2-b/tests/texp.c
+--- mpfr-3.1.2-a/tests/texp.c 2013-03-13 15:37:44.000000000 +0000
++++ mpfr-3.1.2-b/tests/texp.c 2014-04-15 22:04:57.126287230 +0000
+@@ -150,6 +150,22 @@
+ exit (1);
+ }
+
++ mpfr_set_prec (x, 118);
++ mpfr_set_str_binary (x, "0.1110010100011101010000111110011000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E-86");
++ mpfr_set_prec (y, 118);
++ mpfr_exp_2 (y, x, MPFR_RNDU);
++ mpfr_exp_3 (x, x, MPFR_RNDU);
++ if (mpfr_cmp (x, y))
++ {
++ printf ("mpfr_exp_2 and mpfr_exp_3 differ for prec=118\n");
++ printf ("mpfr_exp_2 gives ");
++ mpfr_out_str (stdout, 2, 0, y, MPFR_RNDN);
++ printf ("\nmpfr_exp_3 gives ");
++ mpfr_out_str (stdout, 2, 0, x, MPFR_RNDN);
++ printf ("\n");
++ exit (1);
++ }
++
+ mpfr_clear (x);
+ mpfr_clear (y);
+ return 0;
diff --git a/dev-libs/mpfr/files/3.1.2/patch08 b/dev-libs/mpfr/files/3.1.2/patch08
new file mode 100644
index 000000000000..2245c7c23ec4
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch08
@@ -0,0 +1,254 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2014-04-15 22:20:32.243481506 +0000
++++ mpfr-3.1.2-b/PATCHES 2014-04-15 22:22:32.418722707 +0000
+@@ -0,0 +1 @@
++gmp6-compat
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2014-04-15 22:20:20.755171478 +0000
++++ mpfr-3.1.2-b/VERSION 2014-04-15 22:21:45.225450147 +0000
+@@ -1 +1 @@
+-3.1.2-p7
++3.1.2-p8
+diff -Naurd mpfr-3.1.2-a/configure mpfr-3.1.2-b/configure
+--- mpfr-3.1.2-a/configure 2013-03-13 15:38:20.000000000 +0000
++++ mpfr-3.1.2-b/configure 2014-04-15 22:21:38.821277476 +0000
+@@ -14545,26 +14545,30 @@
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+
+-if test "$use_gmp_build" = yes ; then
+- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for valid GMP_NUMB_BITS" >&5
+-$as_echo_n "checking for valid GMP_NUMB_BITS... " >&6; }
+- if test "$cross_compiling" = yes; then :
++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency" >&5
++$as_echo_n "checking for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency... " >&6; }
++if test "$cross_compiling" = yes; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: can't test" >&5
+ $as_echo "can't test" >&6; }
+ else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+ /* end confdefs.h. */
+
++#include <stdio.h>
+ #include <limits.h>
+ #include "gmp.h"
+-#include "gmp-impl.h"
+
+ int
+ main ()
+ {
+
+- return GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
+- && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
++ if (GMP_NUMB_BITS == sizeof(mp_limb_t) * CHAR_BIT)
++ return 0;
++ fprintf (stderr, "GMP_NUMB_BITS = %ld\n", (long) GMP_NUMB_BITS);
++ fprintf (stderr, "sizeof(mp_limb_t) = %ld\n", (long) sizeof(mp_limb_t));
++ fprintf (stderr, "sizeof(mp_limb_t) * CHAR_BIT = %ld != GMP_NUMB_BITS\n",
++ (long) (sizeof(mp_limb_t) * CHAR_BIT));
++ return 1;
+
+ ;
+ return 0;
+@@ -14577,14 +14581,14 @@
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+ $as_echo "no" >&6; }
+- as_fn_error $? "GMP_NUMB_BITS is incorrect.
+-You probably need to change some of the GMP or MPFR compile options." "$LINENO" 5
++ as_fn_error $? "GMP_NUMB_BITS and sizeof(mp_limb_t) are not consistent.
++You probably need to change some of the GMP or MPFR compile options.
++See 'config.log' for details (search for GMP_NUMB_BITS)." "$LINENO" 5
+ fi
+ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+ fi
+
+-fi
+
+
+ if test "$dont_link_with_gmp" = yes ; then
+diff -Naurd mpfr-3.1.2-a/configure.ac mpfr-3.1.2-b/configure.ac
+--- mpfr-3.1.2-a/configure.ac 2013-03-13 15:37:46.000000000 +0000
++++ mpfr-3.1.2-b/configure.ac 2013-03-13 15:37:46.000000000 +0000
+@@ -435,23 +435,29 @@
+ ])
+ fi
+
+-dnl Check for valid GMP_NUMB_BITS and BYTES_PER_MP_LIMB
++dnl Check for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency.
++dnl Problems may occur if gmp.h was generated with some ABI
++dnl and is used with another ABI (or if nails are used).
+ dnl This test doesn't need to link with libgmp (at least it shouldn't).
+-if test "$use_gmp_build" = yes ; then
+- AC_MSG_CHECKING(for valid GMP_NUMB_BITS)
+- AC_RUN_IFELSE([AC_LANG_PROGRAM([[
++AC_MSG_CHECKING(for GMP_NUMB_BITS and sizeof(mp_limb_t) consistency)
++AC_RUN_IFELSE([AC_LANG_PROGRAM([[
++#include <stdio.h>
+ #include <limits.h>
+ #include "gmp.h"
+-#include "gmp-impl.h"
+ ]], [[
+- return GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
+- && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB ? 0 : 1;
++ if (GMP_NUMB_BITS == sizeof(mp_limb_t) * CHAR_BIT)
++ return 0;
++ fprintf (stderr, "GMP_NUMB_BITS = %ld\n", (long) GMP_NUMB_BITS);
++ fprintf (stderr, "sizeof(mp_limb_t) = %ld\n", (long) sizeof(mp_limb_t));
++ fprintf (stderr, "sizeof(mp_limb_t) * CHAR_BIT = %ld != GMP_NUMB_BITS\n",
++ (long) (sizeof(mp_limb_t) * CHAR_BIT));
++ return 1;
+ ]])], [AC_MSG_RESULT(yes)], [
+ AC_MSG_RESULT(no)
+- AC_MSG_ERROR([GMP_NUMB_BITS is incorrect.
+-You probably need to change some of the GMP or MPFR compile options.])],
++ AC_MSG_ERROR([GMP_NUMB_BITS and sizeof(mp_limb_t) are not consistent.
++You probably need to change some of the GMP or MPFR compile options.
++See 'config.log' for details (search for GMP_NUMB_BITS).])],
+ [AC_MSG_RESULT([can't test])])
+-fi
+
+
+ dnl We really need to link using libtool. But it is impossible with the current
+diff -Naurd mpfr-3.1.2-a/src/init2.c mpfr-3.1.2-b/src/init2.c
+--- mpfr-3.1.2-a/src/init2.c 2013-03-13 15:37:32.000000000 +0000
++++ mpfr-3.1.2-b/src/init2.c 2014-04-15 22:21:06.220398489 +0000
+@@ -30,11 +30,11 @@
+
+ /* Check if we can represent the number of limbs
+ * associated to the maximum of mpfr_prec_t*/
+- MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/BYTES_PER_MP_LIMB) );
++ MPFR_ASSERTN( MP_SIZE_T_MAX >= (MPFR_PREC_MAX/MPFR_BYTES_PER_MP_LIMB) );
+
+- /* Check for correct GMP_NUMB_BITS and BYTES_PER_MP_LIMB */
+- MPFR_ASSERTN( GMP_NUMB_BITS == BYTES_PER_MP_LIMB * CHAR_BIT
+- && sizeof(mp_limb_t) == BYTES_PER_MP_LIMB );
++ /* Check for correct GMP_NUMB_BITS and MPFR_BYTES_PER_MP_LIMB */
++ MPFR_ASSERTN( GMP_NUMB_BITS == MPFR_BYTES_PER_MP_LIMB * CHAR_BIT
++ && sizeof(mp_limb_t) == MPFR_BYTES_PER_MP_LIMB );
+
+ MPFR_ASSERTN (mp_bits_per_limb == GMP_NUMB_BITS);
+
+diff -Naurd mpfr-3.1.2-a/src/mpfr-gmp.h mpfr-3.1.2-b/src/mpfr-gmp.h
+--- mpfr-3.1.2-a/src/mpfr-gmp.h 2013-03-13 15:37:32.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr-gmp.h 2014-04-15 22:21:06.220398489 +0000
+@@ -72,7 +72,6 @@
+ #endif
+
+ /* Define some macros */
+-#define BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
+
+ #define MP_LIMB_T_MAX (~(mp_limb_t)0)
+
+@@ -96,19 +95,19 @@
+ #define SHRT_HIGHBIT SHRT_MIN
+
+ /* MP_LIMB macros */
+-#define MPN_ZERO(dst, n) memset((dst), 0, (n)*BYTES_PER_MP_LIMB)
+-#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
+-#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*BYTES_PER_MP_LIMB)
++#define MPN_ZERO(dst, n) memset((dst), 0, (n)*MPFR_BYTES_PER_MP_LIMB)
++#define MPN_COPY_DECR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
++#define MPN_COPY_INCR(dst,src,n) memmove((dst),(src),(n)*MPFR_BYTES_PER_MP_LIMB)
+ #define MPN_COPY(dst,src,n) \
+ do \
+ { \
+ if ((dst) != (src)) \
+ { \
+ MPFR_ASSERTD ((char *) (dst) >= (char *) (src) + \
+- (n) * BYTES_PER_MP_LIMB || \
++ (n) * MPFR_BYTES_PER_MP_LIMB || \
+ (char *) (src) >= (char *) (dst) + \
+- (n) * BYTES_PER_MP_LIMB); \
+- memcpy ((dst), (src), (n) * BYTES_PER_MP_LIMB); \
++ (n) * MPFR_BYTES_PER_MP_LIMB); \
++ memcpy ((dst), (src), (n) * MPFR_BYTES_PER_MP_LIMB); \
+ } \
+ } \
+ while (0)
+diff -Naurd mpfr-3.1.2-a/src/mpfr-impl.h mpfr-3.1.2-b/src/mpfr-impl.h
+--- mpfr-3.1.2-a/src/mpfr-impl.h 2013-10-09 13:34:21.000000000 +0000
++++ mpfr-3.1.2-b/src/mpfr-impl.h 2014-04-15 22:21:06.220398489 +0000
+@@ -191,7 +191,7 @@
+ # endif
+ #endif
+
+-
++#define MPFR_BYTES_PER_MP_LIMB (GMP_NUMB_BITS/CHAR_BIT)
+
+ /******************************************************
+ ******************** Check GMP ***********************
+@@ -930,7 +930,7 @@
+ #define MPFR_SET_ALLOC_SIZE(x, n) \
+ ( ((mp_size_t*) MPFR_MANT(x))[-1] = n)
+ #define MPFR_MALLOC_SIZE(s) \
+- ( sizeof(mpfr_size_limb_t) + BYTES_PER_MP_LIMB * ((size_t) s) )
++ ( sizeof(mpfr_size_limb_t) + MPFR_BYTES_PER_MP_LIMB * ((size_t) s) )
+ #define MPFR_SET_MANT_PTR(x,p) \
+ (MPFR_MANT(x) = (mp_limb_t*) ((mpfr_size_limb_t*) p + 1))
+ #define MPFR_GET_REAL_PTR(x) \
+@@ -964,7 +964,7 @@
+ #endif
+
+ #define MPFR_TMP_LIMBS_ALLOC(N) \
+- ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * BYTES_PER_MP_LIMB))
++ ((mp_limb_t *) MPFR_TMP_ALLOC ((size_t) (N) * MPFR_BYTES_PER_MP_LIMB))
+
+ /* temporary allocate 1 limb at xp, and initialize mpfr variable x */
+ /* The temporary var doesn't have any size field, but it doesn't matter
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2014-04-15 22:20:20.755171478 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2014-04-15 22:21:45.225450147 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p7"
++#define MPFR_VERSION_STRING "3.1.2-p8"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/mul.c mpfr-3.1.2-b/src/mul.c
+--- mpfr-3.1.2-a/src/mul.c 2013-03-13 15:37:37.000000000 +0000
++++ mpfr-3.1.2-b/src/mul.c 2014-04-15 22:21:06.224398597 +0000
+@@ -106,7 +106,7 @@
+ MPFR_ASSERTD(tn <= k);
+
+ /* Check for no size_t overflow*/
+- MPFR_ASSERTD((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
++ MPFR_ASSERTD((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK(marker);
+ tmp = MPFR_TMP_LIMBS_ALLOC (k);
+
+@@ -301,7 +301,7 @@
+ MPFR_ASSERTD (tn <= k); /* tn <= k, thus no int overflow */
+
+ /* Check for no size_t overflow*/
+- MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / BYTES_PER_MP_LIMB);
++ MPFR_ASSERTD ((size_t) k <= ((size_t) -1) / MPFR_BYTES_PER_MP_LIMB);
+ MPFR_TMP_MARK (marker);
+ tmp = MPFR_TMP_LIMBS_ALLOC (k);
+
+diff -Naurd mpfr-3.1.2-a/src/stack_interface.c mpfr-3.1.2-b/src/stack_interface.c
+--- mpfr-3.1.2-a/src/stack_interface.c 2013-03-13 15:37:32.000000000 +0000
++++ mpfr-3.1.2-b/src/stack_interface.c 2014-04-15 22:21:06.220398489 +0000
+@@ -26,7 +26,7 @@
+ size_t
+ mpfr_custom_get_size (mpfr_prec_t prec)
+ {
+- return MPFR_PREC2LIMBS (prec) * BYTES_PER_MP_LIMB;
++ return MPFR_PREC2LIMBS (prec) * MPFR_BYTES_PER_MP_LIMB;
+ }
+
+ #undef mpfr_custom_init
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2014-04-15 22:20:20.755171478 +0000
++++ mpfr-3.1.2-b/src/version.c 2014-04-15 22:21:45.225450147 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p7";
++ return "3.1.2-p8";
+ }
diff --git a/dev-libs/mpfr/files/3.1.2/patch09 b/dev-libs/mpfr/files/3.1.2/patch09
new file mode 100644
index 000000000000..6ff7c4ac92e7
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch09
@@ -0,0 +1,166 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2014-06-30 15:15:25.533266905 +0000
++++ mpfr-3.1.2-b/PATCHES 2014-06-30 15:15:25.617269178 +0000
+@@ -0,0 +1 @@
++div-overflow
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2014-06-30 15:15:25.529266797 +0000
++++ mpfr-3.1.2-b/VERSION 2014-06-30 15:15:25.617269178 +0000
+@@ -1 +1 @@
+-3.1.2-p8
++3.1.2-p9
+diff -Naurd mpfr-3.1.2-a/src/div.c mpfr-3.1.2-b/src/div.c
+--- mpfr-3.1.2-a/src/div.c 2013-03-13 15:37:33.000000000 +0000
++++ mpfr-3.1.2-b/src/div.c 2014-06-30 15:15:25.585268312 +0000
+@@ -750,7 +750,9 @@
+ truncate_check_qh:
+ if (qh)
+ {
+- qexp ++;
++ if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
++ qexp ++;
++ /* else qexp is now incorrect, but one will still get an overflow */
+ q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
+ }
+ goto truncate;
+@@ -765,7 +767,9 @@
+ inex = 1; /* always here */
+ if (mpn_add_1 (q0p, q0p, q0size, MPFR_LIMB_ONE << sh))
+ {
+- qexp ++;
++ if (MPFR_LIKELY (qexp < MPFR_EXP_MAX))
++ qexp ++;
++ /* else qexp is now incorrect, but one will still get an overflow */
+ q0p[q0size - 1] = MPFR_LIMB_HIGHBIT;
+ }
+
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2014-06-30 15:15:25.533266905 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2014-06-30 15:15:25.613269070 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p8"
++#define MPFR_VERSION_STRING "3.1.2-p9"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2014-06-30 15:15:25.533266905 +0000
++++ mpfr-3.1.2-b/src/version.c 2014-06-30 15:15:25.613269070 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p8";
++ return "3.1.2-p9";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/tdiv.c mpfr-3.1.2-b/tests/tdiv.c
+--- mpfr-3.1.2-a/tests/tdiv.c 2013-03-13 15:37:44.000000000 +0000
++++ mpfr-3.1.2-b/tests/tdiv.c 2014-06-30 15:15:25.585268312 +0000
+@@ -1104,6 +1104,96 @@
+ #define RAND_FUNCTION(x) mpfr_random2(x, MPFR_LIMB_SIZE (x), randlimb () % 100, RANDS)
+ #include "tgeneric.c"
+
++static void
++test_extreme (void)
++{
++ mpfr_t x, y, z;
++ mpfr_exp_t emin, emax;
++ mpfr_prec_t p[4] = { 8, 32, 64, 256 };
++ int xi, yi, zi, j, r;
++ unsigned int flags, ex_flags;
++
++ emin = mpfr_get_emin ();
++ emax = mpfr_get_emax ();
++
++ mpfr_set_emin (MPFR_EMIN_MIN);
++ mpfr_set_emax (MPFR_EMAX_MAX);
++
++ for (xi = 0; xi < 4; xi++)
++ {
++ mpfr_init2 (x, p[xi]);
++ mpfr_setmax (x, MPFR_EMAX_MAX);
++ MPFR_ASSERTN (mpfr_check (x));
++ for (yi = 0; yi < 4; yi++)
++ {
++ mpfr_init2 (y, p[yi]);
++ mpfr_setmin (y, MPFR_EMIN_MIN);
++ for (j = 0; j < 2; j++)
++ {
++ MPFR_ASSERTN (mpfr_check (y));
++ for (zi = 0; zi < 4; zi++)
++ {
++ mpfr_init2 (z, p[zi]);
++ RND_LOOP (r)
++ {
++ mpfr_clear_flags ();
++ mpfr_div (z, x, y, (mpfr_rnd_t) r);
++ flags = __gmpfr_flags;
++ MPFR_ASSERTN (mpfr_check (z));
++ ex_flags = MPFR_FLAGS_OVERFLOW | MPFR_FLAGS_INEXACT;
++ if (flags != ex_flags)
++ {
++ printf ("Bad flags in test_extreme on z = a/b"
++ " with %s and\n",
++ mpfr_print_rnd_mode ((mpfr_rnd_t) r));
++ printf ("a = ");
++ mpfr_dump (x);
++ printf ("b = ");
++ mpfr_dump (y);
++ printf ("Expected flags:");
++ flags_out (ex_flags);
++ printf ("Got flags: ");
++ flags_out (flags);
++ printf ("z = ");
++ mpfr_dump (z);
++ exit (1);
++ }
++ mpfr_clear_flags ();
++ mpfr_div (z, y, x, (mpfr_rnd_t) r);
++ flags = __gmpfr_flags;
++ MPFR_ASSERTN (mpfr_check (z));
++ ex_flags = MPFR_FLAGS_UNDERFLOW | MPFR_FLAGS_INEXACT;
++ if (flags != ex_flags)
++ {
++ printf ("Bad flags in test_extreme on z = a/b"
++ " with %s and\n",
++ mpfr_print_rnd_mode ((mpfr_rnd_t) r));
++ printf ("a = ");
++ mpfr_dump (y);
++ printf ("b = ");
++ mpfr_dump (x);
++ printf ("Expected flags:");
++ flags_out (ex_flags);
++ printf ("Got flags: ");
++ flags_out (flags);
++ printf ("z = ");
++ mpfr_dump (z);
++ exit (1);
++ }
++ }
++ mpfr_clear (z);
++ } /* zi */
++ mpfr_nextabove (y);
++ } /* j */
++ mpfr_clear (y);
++ } /* yi */
++ mpfr_clear (x);
++ } /* xi */
++
++ set_emin (emin);
++ set_emax (emax);
++}
++
+ int
+ main (int argc, char *argv[])
+ {
+@@ -1130,6 +1220,7 @@
+ test_20070603 ();
+ test_20070628 ();
+ test_generic (2, 800, 50);
++ test_extreme ();
+
+ tests_end_mpfr ();
+ return 0;
diff --git a/dev-libs/mpfr/files/3.1.2/patch10 b/dev-libs/mpfr/files/3.1.2/patch10
new file mode 100644
index 000000000000..43848f7b1166
--- /dev/null
+++ b/dev-libs/mpfr/files/3.1.2/patch10
@@ -0,0 +1,138 @@
+diff -Naurd mpfr-3.1.2-a/PATCHES mpfr-3.1.2-b/PATCHES
+--- mpfr-3.1.2-a/PATCHES 2014-06-30 15:17:53.337268149 +0000
++++ mpfr-3.1.2-b/PATCHES 2014-06-30 15:17:53.417270314 +0000
+@@ -0,0 +1 @@
++vasprintf
+diff -Naurd mpfr-3.1.2-a/VERSION mpfr-3.1.2-b/VERSION
+--- mpfr-3.1.2-a/VERSION 2014-06-30 15:17:53.337268149 +0000
++++ mpfr-3.1.2-b/VERSION 2014-06-30 15:17:53.413270206 +0000
+@@ -1 +1 @@
+-3.1.2-p9
++3.1.2-p10
+diff -Naurd mpfr-3.1.2-a/src/mpfr.h mpfr-3.1.2-b/src/mpfr.h
+--- mpfr-3.1.2-a/src/mpfr.h 2014-06-30 15:17:53.337268149 +0000
++++ mpfr-3.1.2-b/src/mpfr.h 2014-06-30 15:17:53.413270206 +0000
+@@ -27,7 +27,7 @@
+ #define MPFR_VERSION_MAJOR 3
+ #define MPFR_VERSION_MINOR 1
+ #define MPFR_VERSION_PATCHLEVEL 2
+-#define MPFR_VERSION_STRING "3.1.2-p9"
++#define MPFR_VERSION_STRING "3.1.2-p10"
+
+ /* Macros dealing with MPFR VERSION */
+ #define MPFR_VERSION_NUM(a,b,c) (((a) << 16L) | ((b) << 8) | (c))
+diff -Naurd mpfr-3.1.2-a/src/vasprintf.c mpfr-3.1.2-b/src/vasprintf.c
+--- mpfr-3.1.2-a/src/vasprintf.c 2013-11-15 00:51:49.267334408 +0000
++++ mpfr-3.1.2-b/src/vasprintf.c 2014-06-30 15:17:53.377269231 +0000
+@@ -884,14 +884,18 @@
+ first digit, we want the exponent for radix two and the decimal
+ point AFTER the first digit. */
+ {
+- MPFR_ASSERTN (exp > MPFR_EMIN_MIN /4); /* possible overflow */
++ /* An integer overflow is normally not possible since MPFR_EXP_MIN
++ is twice as large as MPFR_EMIN_MIN. */
++ MPFR_ASSERTN (exp > (MPFR_EXP_MIN + 3) / 4);
+ exp = (exp - 1) * 4;
+ }
+ else
+ /* EXP is the exponent for decimal point BEFORE the first digit, we
+ want the exponent for decimal point AFTER the first digit. */
+ {
+- MPFR_ASSERTN (exp > MPFR_EMIN_MIN); /* possible overflow */
++ /* An integer overflow is normally not possible since MPFR_EXP_MIN
++ is twice as large as MPFR_EMIN_MIN. */
++ MPFR_ASSERTN (exp > MPFR_EXP_MIN);
+ --exp;
+ }
+ }
+diff -Naurd mpfr-3.1.2-a/src/version.c mpfr-3.1.2-b/src/version.c
+--- mpfr-3.1.2-a/src/version.c 2014-06-30 15:17:53.337268149 +0000
++++ mpfr-3.1.2-b/src/version.c 2014-06-30 15:17:53.413270206 +0000
+@@ -25,5 +25,5 @@
+ const char *
+ mpfr_get_version (void)
+ {
+- return "3.1.2-p9";
++ return "3.1.2-p10";
+ }
+diff -Naurd mpfr-3.1.2-a/tests/tsprintf.c mpfr-3.1.2-b/tests/tsprintf.c
+--- mpfr-3.1.2-a/tests/tsprintf.c 2013-11-15 00:51:49.267334408 +0000
++++ mpfr-3.1.2-b/tests/tsprintf.c 2014-06-30 15:17:53.377269231 +0000
+@@ -1184,6 +1184,69 @@
+ check_emax_aux (MPFR_EMAX_MAX);
+ }
+
++static void
++check_emin_aux (mpfr_exp_t e)
++{
++ mpfr_t x;
++ char *s1, s2[256];
++ int i;
++ mpfr_exp_t emin;
++ mpz_t ee;
++
++ MPFR_ASSERTN (e >= LONG_MIN);
++ emin = mpfr_get_emin ();
++ set_emin (e);
++
++ mpfr_init2 (x, 16);
++ mpz_init (ee);
++
++ mpfr_setmin (x, e);
++ mpz_set_si (ee, e);
++ mpz_sub_ui (ee, ee, 1);
++
++ i = mpfr_asprintf (&s1, "%Ra", x);
++ MPFR_ASSERTN (i > 0);
++
++ gmp_snprintf (s2, 256, "0x1p%Zd", ee);
++
++ if (strcmp (s1, s2) != 0)
++ {
++ printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
++ printf ("Expected %s\n", s2);
++ printf ("Got %s\n", s1);
++ exit (1);
++ }
++
++ mpfr_free_str (s1);
++
++ i = mpfr_asprintf (&s1, "%Rb", x);
++ MPFR_ASSERTN (i > 0);
++
++ gmp_snprintf (s2, 256, "1p%Zd", ee);
++
++ if (strcmp (s1, s2) != 0)
++ {
++ printf ("Error in check_emin_aux for emin = %ld\n", (long) e);
++ printf ("Expected %s\n", s2);
++ printf ("Got %s\n", s1);
++ exit (1);
++ }
++
++ mpfr_free_str (s1);
++
++ mpfr_clear (x);
++ mpz_clear (ee);
++ set_emin (emin);
++}
++
++static void
++check_emin (void)
++{
++ check_emin_aux (-15);
++ check_emin_aux (mpfr_get_emin ());
++ check_emin_aux (MPFR_EMIN_MIN);
++}
++
+ int
+ main (int argc, char **argv)
+ {
+@@ -1203,6 +1266,7 @@
+ decimal ();
+ mixed ();
+ check_emax ();
++ check_emin ();
+
+ #if defined(HAVE_LOCALE_H) && defined(HAVE_SETLOCALE)
+ locale_da_DK ();
diff --git a/dev-libs/mpfr/metadata.xml b/dev-libs/mpfr/metadata.xml
new file mode 100644
index 000000000000..fb4199eb7afe
--- /dev/null
+++ b/dev-libs/mpfr/metadata.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>toolchain</herd>
+</pkgmetadata>
diff --git a/dev-libs/mpfr/mpfr-2.4.2_p3-r1.ebuild b/dev-libs/mpfr/mpfr-2.4.2_p3-r1.ebuild
new file mode 100644
index 000000000000..f97d812be714
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-2.4.2_p3-r1.ebuild
@@ -0,0 +1,47 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# this ebuild is only for the libmpfr.so.1 ABI SONAME
+
+EAPI="4"
+
+inherit eutils libtool flag-o-matic
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="1"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd ~ppc-aix ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE=""
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ epatch "${FILESDIR}"/${MY_PV}/patch*
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -exec touch -r configure {} +
+ elibtoolize
+}
+
+src_configure() {
+ # Newer gmp has deleted this define, so export it for older mpfr.
+ append-cppflags -D__gmp_const=const
+ econf --disable-static
+}
+
+src_compile() {
+ emake libmpfr.la
+}
+
+src_install() {
+ emake install-libLTLIBRARIES DESTDIR="${D}"
+ rm -f "${ED}"/usr/*/libmpfr.{la,so,dylib,a}
+}
diff --git a/dev-libs/mpfr/mpfr-3.0.0_p3.ebuild b/dev-libs/mpfr/mpfr-3.0.0_p3.ebuild
new file mode 100644
index 000000000000..bb43fe2e90d0
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.0.0_p3.ebuild
@@ -0,0 +1,59 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ rm "${D}"/usr/share/doc/${PN}/*.html || die
+ mv "${D}"/usr/share/doc/{${PN},${PF}} || die
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ dohtml *.html
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.0.1.ebuild b/dev-libs/mpfr/mpfr-3.0.1.ebuild
new file mode 100644
index 000000000000..0bfc5bbbe760
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.0.1.ebuild
@@ -0,0 +1,59 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ rm "${D}"/usr/share/doc/${PN}/*.html || die
+ mv "${D}"/usr/share/doc/{${PN},${PF}} || die
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ dohtml *.html
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.0.1_p4-r1.ebuild b/dev-libs/mpfr/mpfr-3.0.1_p4-r1.ebuild
new file mode 100644
index 000000000000..9f726f07915b
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.0.1_p4-r1.ebuild
@@ -0,0 +1,64 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_configure() {
+ econf $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${D}"/usr/$(get_libdir)/libmpfr.la
+ rm "${D}"/usr/share/doc/${PN}/*.html || die
+ mv "${D}"/usr/share/doc/{${PN},${PF}} || die
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ dohtml *.html
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.0.1_p4.ebuild b/dev-libs/mpfr/mpfr-3.0.1_p4.ebuild
new file mode 100644
index 000000000000..bb43fe2e90d0
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.0.1_p4.ebuild
@@ -0,0 +1,59 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~sparc-fbsd ~x86-fbsd"
+IUSE=""
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_unpack() {
+ unpack ${A}
+ cd "${S}"
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ rm "${D}"/usr/share/doc/${PN}/*.html || die
+ mv "${D}"/usr/share/doc/{${PN},${PF}} || die
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ dohtml *.html
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.0.ebuild b/dev-libs/mpfr/mpfr-3.1.0.ebuild
new file mode 100644
index 000000000000..d44663f1c563
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.0.ebuild
@@ -0,0 +1,69 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 -sparc-fbsd -x86-fbsd"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_configure() {
+ econf \
+ --docdir=/usr/share/doc/${PF} \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${D}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${D}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.0_p7.ebuild b/dev-libs/mpfr/mpfr-3.1.0_p7.ebuild
new file mode 100644
index 000000000000..14cdee533be0
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.0_p7.ebuild
@@ -0,0 +1,69 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.bz2"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_configure() {
+ econf \
+ --docdir=/usr/share/doc/${PF} \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${D}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${D}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.1.ebuild b/dev-libs/mpfr/mpfr-3.1.1.ebuild
new file mode 100644
index 000000000000..8dd4b65ba214
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.1.ebuild
@@ -0,0 +1,69 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="alpha amd64 arm hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_configure() {
+ econf \
+ --docdir=/usr/share/doc/${PF} \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${D}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${D}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.1_p2.ebuild b/dev-libs/mpfr/mpfr-3.1.1_p2.ebuild
new file mode 100644
index 000000000000..cb40ece105a9
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.1_p2.ebuild
@@ -0,0 +1,69 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~arm-linux ~x86-linux"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ [[ ${PLEVEL} == ${PV} ]] && return 0
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -print0 | xargs -0 touch -r configure
+}
+
+src_configure() {
+ econf \
+ --docdir="${EPREFIX}"/usr/share/doc/${PF} \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${ED}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${ED}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr.so.1
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr.so.1
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.2-r1.ebuild b/dev-libs/mpfr/mpfr-3.1.2-r1.ebuild
new file mode 100644
index 000000000000..1677e3bbcd8e
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.2-r1.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils libtool multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 ~m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ if [[ ${PLEVEL} != ${PV} ]] ; then
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ fi
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -exec touch -r configure {} +
+ elibtoolize
+}
+
+src_configure() {
+ # Make sure mpfr doesn't go probing toolchains it shouldn't #476336#19
+ user_redefine_cc=yes \
+ econf \
+ --docdir="\$(datarootdir)/doc/${PF}" \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${ED}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${ED}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.2_p10.ebuild b/dev-libs/mpfr/mpfr-3.1.2_p10.ebuild
new file mode 100644
index 000000000000..90b92c02107d
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.2_p10.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="4"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils libtool multilib multilib-minimal
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[${MULTILIB_USEDEP},static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ if [[ ${PLEVEL} != ${PV} ]] ; then
+ local i
+ for (( i = 1; i <= PLEVEL; ++i )) ; do
+ epatch "${FILESDIR}"/${MY_PV}/patch$(printf '%02d' ${i})
+ done
+ fi
+ find . -type f -exec touch -r configure {} +
+ elibtoolize
+}
+
+multilib_src_configure() {
+ # Make sure mpfr doesn't go probing toolchains it shouldn't #476336#19
+ ECONF_SOURCE=${S} \
+ user_redefine_cc=yes \
+ econf \
+ --docdir="\$(datarootdir)/doc/${PF}" \
+ $(use_enable static-libs static)
+}
+
+multilib_src_install_all() {
+ use static-libs || find "${ED}"/usr -name '*.la' -delete
+
+ # clean up html/license install
+ pushd "${ED}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.2_p5.ebuild b/dev-libs/mpfr/mpfr-3.1.2_p5.ebuild
new file mode 100644
index 000000000000..5bca7b2a1fc2
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.2_p5.ebuild
@@ -0,0 +1,73 @@
+# Copyright 1999-2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="3"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils libtool multilib
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ if [[ ${PLEVEL} != ${PV} ]] ; then
+ for ((i=1; i<=PLEVEL; ++i)) ; do
+ patch=patch$(printf '%02d' ${i})
+ if [[ -f ${FILESDIR}/${MY_PV}/${patch} ]] ; then
+ epatch "${FILESDIR}"/${MY_PV}/${patch}
+ elif [[ -f ${DISTDIR}/${PN}-${MY_PV}_p${i} ]] ; then
+ epatch "${DISTDIR}"/${PN}-${MY_PV}_p${i}
+ else
+ ewarn "${DISTDIR}/${PN}-${MY_PV}_p${i}"
+ die "patch ${i} missing - please report to bugs.gentoo.org"
+ fi
+ done
+ fi
+ sed -i '/if test/s:==:=:' configure #261016
+ find . -type f -exec touch -r configure {} +
+ elibtoolize
+}
+
+src_configure() {
+ # Make sure mpfr doesn't go probing toolchains it shouldn't #476336#19
+ user_redefine_cc=yes \
+ econf \
+ --docdir="\$(datarootdir)/doc/${PF}" \
+ $(use_enable static-libs static)
+}
+
+src_install() {
+ emake install DESTDIR="${D}" || die
+ use static-libs || rm -f "${ED}"/usr/$(get_libdir)/libmpfr.la
+
+ # clean up html/license install
+ pushd "${ED}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+ # some, but not all, are already installed
+ dodoc AUTHORS BUGS ChangeLog NEWS README TODO
+ prepalldocs
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
diff --git a/dev-libs/mpfr/mpfr-3.1.3.ebuild b/dev-libs/mpfr/mpfr-3.1.3.ebuild
new file mode 100644
index 000000000000..89ceb0a5f7a5
--- /dev/null
+++ b/dev-libs/mpfr/mpfr-3.1.3.ebuild
@@ -0,0 +1,62 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI="4"
+
+# NOTE: we cannot depend on autotools here starting with gcc-4.3.x
+inherit eutils libtool multilib multilib-minimal
+
+MY_PV=${PV/_p*}
+MY_P=${PN}-${MY_PV}
+PLEVEL=${PV/*p}
+DESCRIPTION="library for multiple-precision floating-point computations with exact rounding"
+HOMEPAGE="http://www.mpfr.org/"
+SRC_URI="http://www.mpfr.org/mpfr-${MY_PV}/${MY_P}.tar.xz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~sparc-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux ~ia64-hpux ~x86-interix ~amd64-linux ~arm-linux ~ia64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
+IUSE="static-libs"
+
+RDEPEND=">=dev-libs/gmp-4.1.4-r2[${MULTILIB_USEDEP},static-libs?]"
+DEPEND="${RDEPEND}"
+
+S=${WORKDIR}/${MY_P}
+
+src_prepare() {
+ if [[ ${PLEVEL} != ${PV} ]] ; then
+ local i
+ for (( i = 1; i <= PLEVEL; ++i )) ; do
+ epatch "${FILESDIR}"/${MY_PV}/patch$(printf '%02d' ${i})
+ done
+ fi
+ find . -type f -exec touch -r configure {} +
+ elibtoolize
+}
+
+multilib_src_configure() {
+ # Make sure mpfr doesn't go probing toolchains it shouldn't #476336#19
+ ECONF_SOURCE=${S} \
+ user_redefine_cc=yes \
+ econf \
+ --docdir="\$(datarootdir)/doc/${PF}" \
+ $(use_enable static-libs static)
+}
+
+multilib_src_install_all() {
+ use static-libs || find "${ED}"/usr -name '*.la' -delete
+
+ # clean up html/license install
+ pushd "${ED}"/usr/share/doc/${PF} >/dev/null
+ dohtml *.html && rm COPYING* *.html || die
+ popd >/dev/null
+}
+
+pkg_preinst() {
+ preserve_old_lib /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}
+
+pkg_postinst() {
+ preserve_old_lib_notify /usr/$(get_libdir)/libmpfr$(get_libname 1)
+}