summaryrefslogtreecommitdiff
path: root/packages/mpfr
diff options
context:
space:
mode:
Diffstat (limited to 'packages/mpfr')
-rw-r--r--packages/mpfr/2.4.2/100-sin_cos_underflow.patch184
-rw-r--r--packages/mpfr/2.4.2/110-longlong.h.patch71
-rw-r--r--packages/mpfr/2.4.2/120-gmp5.patch75
-rw-r--r--packages/mpfr/2.4.2/version.desc1
-rw-r--r--packages/mpfr/3.0.1/110-asin_exprange.patch137
-rw-r--r--packages/mpfr/3.0.1/120-rec_sqrt-carry.patch76
-rw-r--r--packages/mpfr/3.0.1/130-atan-expo-range.patch107
-rw-r--r--packages/mpfr/3.0.1/140-texp-zero.patch47
-rw-r--r--packages/mpfr/3.0.1/version.desc1
-rw-r--r--packages/mpfr/3.1.5/version.desc0
-rw-r--r--packages/mpfr/package.desc5
11 files changed, 704 insertions, 0 deletions
diff --git a/packages/mpfr/2.4.2/100-sin_cos_underflow.patch b/packages/mpfr/2.4.2/100-sin_cos_underflow.patch
new file mode 100644
index 0000000..2721517
--- /dev/null
+++ b/packages/mpfr/2.4.2/100-sin_cos_underflow.patch
@@ -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/packages/mpfr/2.4.2/110-longlong.h.patch b/packages/mpfr/2.4.2/110-longlong.h.patch
new file mode 100644
index 0000000..fa85d8e
--- /dev/null
+++ b/packages/mpfr/2.4.2/110-longlong.h.patch
@@ -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/packages/mpfr/2.4.2/120-gmp5.patch b/packages/mpfr/2.4.2/120-gmp5.patch
new file mode 100644
index 0000000..3ce4952
--- /dev/null
+++ b/packages/mpfr/2.4.2/120-gmp5.patch
@@ -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/packages/mpfr/2.4.2/version.desc b/packages/mpfr/2.4.2/version.desc
new file mode 100644
index 0000000..fcfe389
--- /dev/null
+++ b/packages/mpfr/2.4.2/version.desc
@@ -0,0 +1 @@
+obsolete='yes'
diff --git a/packages/mpfr/3.0.1/110-asin_exprange.patch b/packages/mpfr/3.0.1/110-asin_exprange.patch
new file mode 100644
index 0000000..d79a6f9
--- /dev/null
+++ b/packages/mpfr/3.0.1/110-asin_exprange.patch
@@ -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/packages/mpfr/3.0.1/120-rec_sqrt-carry.patch b/packages/mpfr/3.0.1/120-rec_sqrt-carry.patch
new file mode 100644
index 0000000..0367d84
--- /dev/null
+++ b/packages/mpfr/3.0.1/120-rec_sqrt-carry.patch
@@ -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/packages/mpfr/3.0.1/130-atan-expo-range.patch b/packages/mpfr/3.0.1/130-atan-expo-range.patch
new file mode 100644
index 0000000..251b837
--- /dev/null
+++ b/packages/mpfr/3.0.1/130-atan-expo-range.patch
@@ -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/packages/mpfr/3.0.1/140-texp-zero.patch b/packages/mpfr/3.0.1/140-texp-zero.patch
new file mode 100644
index 0000000..fd74087
--- /dev/null
+++ b/packages/mpfr/3.0.1/140-texp-zero.patch
@@ -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/packages/mpfr/3.0.1/version.desc b/packages/mpfr/3.0.1/version.desc
new file mode 100644
index 0000000..fcfe389
--- /dev/null
+++ b/packages/mpfr/3.0.1/version.desc
@@ -0,0 +1 @@
+obsolete='yes'
diff --git a/packages/mpfr/3.1.5/version.desc b/packages/mpfr/3.1.5/version.desc
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/packages/mpfr/3.1.5/version.desc
diff --git a/packages/mpfr/package.desc b/packages/mpfr/package.desc
new file mode 100644
index 0000000..59cb5d4
--- /dev/null
+++ b/packages/mpfr/package.desc
@@ -0,0 +1,5 @@
+repository='svn https://scm.gforge.inria.fr/anonscm/svn/mpfr'
+# TBD: meta-package autoconf-archive to install extra m4's
+bootstrap='wget -O m4/ax_pthread.m4 \\"http://git.savannah.gnu.org/gitweb/?p=autoconf-archive.git;a=blob_plain;f=m4/ax_pthread.m4\\" && ./autogen.sh'
+mirrors='http://www.mpfr.org/mpfr-${CT_MPFR_VERSION} $(CT_Mirrors GNU mpfr)'
+archive_formats='.tar.xz .tar.bz2 .tar.gz .zip'