summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mpfr-gmp.c13
-rw-r--r--mpfr-gmp.h6
-rw-r--r--tests/mpfr-test.h4
-rw-r--r--tests/reuse.c1
-rw-r--r--tests/tadd.c2
-rw-r--r--tests/tadd_d.c1
-rw-r--r--tests/tadd_ui.c1
-rw-r--r--tests/tagm.c1
-rw-r--r--tests/tcan_round.c7
-rw-r--r--tests/tcbrt.c1
-rw-r--r--tests/td_div.c2
-rw-r--r--tests/td_sub.c1
-rw-r--r--tests/tdiv.c1
-rw-r--r--tests/tdiv_d.c2
-rw-r--r--tests/tdiv_ui.c1
-rw-r--r--tests/tgamma.c1
-rw-r--r--tests/tget_f.c1
-rw-r--r--tests/tli2.c1
-rw-r--r--tests/tmul.c1
-rw-r--r--tests/tmul_d.c2
-rw-r--r--tests/tmul_ui.c1
-rw-r--r--tests/tpow.c1
-rw-r--r--tests/tpow_z.c11
-rw-r--r--tests/trandom.c1
-rw-r--r--tests/troot.c1
-rw-r--r--tests/tset_f.c9
-rw-r--r--tests/tsi_op.c1
-rw-r--r--tests/tsub.c1
-rw-r--r--tests/tsub_d.c1
-rw-r--r--tests/tsub_ui.c1
30 files changed, 22 insertions, 56 deletions
diff --git a/mpfr-gmp.c b/mpfr-gmp.c
index 1d32ac61f..38ba8a82a 100644
--- a/mpfr-gmp.c
+++ b/mpfr-gmp.c
@@ -316,19 +316,6 @@ mpfr_rand_raw (mp_ptr mp, gmp_randstate_t rstate, unsigned long int nbits)
mpz_urandomb(z, rstate, nbits);
}
-void
-mpfr_init_gmp_rand ()
-{
- /* Since we don't use __gmp_rands, but mpfr_rands, we need to init
- __gmp_rands before setting the memory functions so that the tests
- don't report an error.
- Only the tests which call mpn_random2 can do that:
- trandom, tset_f and reuse.
- So we just have to call mpn_random before. */
- mp_limb_t dummy;
- mpn_random (&dummy, 1);
-}
-
#ifdef mp_get_memory_functions
void * (*mpfr_allocate_func) (size_t);
diff --git a/mpfr-gmp.h b/mpfr-gmp.h
index 4d620b7c7..eec22e7a9 100644
--- a/mpfr-gmp.h
+++ b/mpfr-gmp.h
@@ -264,12 +264,6 @@ typedef __gmp_randstate_struct *gmp_randstate_ptr;
__MPFR_DECLSPEC void mpfr_rand_raw _MPFR_PROTO((mp_ptr, gmp_randstate_t,
unsigned long));
-/* To be called BEFORE tests_start_mpfr () if the tests used
- mpfr_random, mpfr_random2 or any functions which uses the macro RANDS */
-__MPFR_DECLSPEC void mpfr_init_gmp_rand _MPFR_PROTO((void));
-#define MPFR_TEST_USE_RANDS() mpfr_init_gmp_rand ();
-
-
/* Allocate func are defined in gmp-impl.h */
/* In newer GMP, there aren't anymore __gmp_allocate_func,
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h
index a799fb475..d59715110 100644
--- a/tests/mpfr-test.h
+++ b/tests/mpfr-test.h
@@ -89,10 +89,6 @@ int mpfr_cmp_str _MPFR_PROTO ((mpfr_srcptr x, const char *, int, mp_rnd_t));
#define mpfr_cmp0(x,y) (MPFR_ASSERTN (!MPFR_IS_NAN (x) && !MPFR_IS_NAN (y)), mpfr_cmp (x,y))
-#ifndef MPFR_TEST_USE_RANDS
-# define MPFR_TEST_USE_RANDS() ((void)0)
-#endif
-
#if defined (__cplusplus)
}
#endif
diff --git a/tests/reuse.c b/tests/reuse.c
index 10b28b438..ab259c0b8 100644
--- a/tests/reuse.c
+++ b/tests/reuse.c
@@ -520,7 +520,6 @@ main (void)
{
mp_rnd_t rnd;
mp_prec_t p;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
p = (randlimb () % 200)+ MPFR_PREC_MIN;
diff --git a/tests/tadd.c b/tests/tadd.c
index 7304bf295..668ade96a 100644
--- a/tests/tadd.c
+++ b/tests/tadd.c
@@ -1076,9 +1076,7 @@ tests (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
- /* mpfr_test_init (); */
usesp = 0;
tests ();
diff --git a/tests/tadd_d.c b/tests/tadd_d.c
index 07843a68e..05ae15b47 100644
--- a/tests/tadd_d.c
+++ b/tests/tadd_d.c
@@ -124,7 +124,6 @@ check_nans (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_nans ();
diff --git a/tests/tadd_ui.c b/tests/tadd_ui.c
index b2fdbe3b7..963c035d6 100644
--- a/tests/tadd_ui.c
+++ b/tests/tadd_ui.c
@@ -96,7 +96,6 @@ check_nans (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_nans ();
diff --git a/tests/tagm.c b/tests/tagm.c
index fc65934c2..8871008fe 100644
--- a/tests/tagm.c
+++ b/tests/tagm.c
@@ -197,7 +197,6 @@ check_nans (void)
int
main (int argc, char* argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_nans ();
diff --git a/tests/tcan_round.c b/tests/tcan_round.c
index 3abdc1c39..1b7c7cb8c 100644
--- a/tests/tcan_round.c
+++ b/tests/tcan_round.c
@@ -31,14 +31,16 @@ static void
check_round_p (void)
{
mp_limb_t buf[MAX_LIMB_SIZE];
- mp_size_t n;
+ mp_size_t n, i;
mp_prec_t p;
mp_exp_t err;
int r1, r2;
for (n = 2 ; n <= MAX_LIMB_SIZE ; n++)
{
- mpn_random (buf, n);
+ /* avoid mpn_random which leaks memory */
+ for (i = 0; i < n; i++)
+ buf[i] = randlimb ();
p = (mp_prec_t) randlimb() % ((n-1) * BITS_PER_MP_LIMB) + MPFR_PREC_MIN;
err = p + randlimb () % BITS_PER_MP_LIMB;
r1 = mpfr_round_p (buf, n, err, p);
@@ -61,7 +63,6 @@ main (void)
mpfr_t x;
mp_prec_t i, j;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
/* checks that rounds to nearest sets the last
diff --git a/tests/tcbrt.c b/tests/tcbrt.c
index 06c6ed673..42bcef1a2 100644
--- a/tests/tcbrt.c
+++ b/tests/tcbrt.c
@@ -155,7 +155,6 @@ main (void)
int r;
mp_prec_t p;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/td_div.c b/tests/td_div.c
index a53b7bd70..74c3ee72b 100644
--- a/tests/td_div.c
+++ b/tests/td_div.c
@@ -72,7 +72,7 @@ main (int argc, char *argv[])
mpfr_t x, y, z;
double d;
int inexact;
- MPFR_TEST_USE_RANDS ();
+
tests_start_mpfr ();
/* check with enough precision */
diff --git a/tests/td_sub.c b/tests/td_sub.c
index e607ede09..836e920fd 100644
--- a/tests/td_sub.c
+++ b/tests/td_sub.c
@@ -67,7 +67,6 @@ main (int argc, char *argv[])
double d;
int inexact;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
/* check with enough precision */
diff --git a/tests/tdiv.c b/tests/tdiv.c
index d30510ae2..7ce51e889 100644
--- a/tests/tdiv.c
+++ b/tests/tdiv.c
@@ -874,7 +874,6 @@ test_20070628 (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_inexact ();
diff --git a/tests/tdiv_d.c b/tests/tdiv_d.c
index 77a5e0352..3f3da8e2e 100644
--- a/tests/tdiv_d.c
+++ b/tests/tdiv_d.c
@@ -71,7 +71,7 @@ main (int argc, char *argv[])
mpfr_t x, y, z;
double d;
int inexact;
- MPFR_TEST_USE_RANDS ();
+
tests_start_mpfr ();
/* check with enough precision */
diff --git a/tests/tdiv_ui.c b/tests/tdiv_ui.c
index 492edc1b3..10850c379 100644
--- a/tests/tdiv_ui.c
+++ b/tests/tdiv_ui.c
@@ -206,7 +206,6 @@ main (int argc, char **argv)
{
mpfr_t x;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/tgamma.c b/tests/tgamma.c
index a04c1205c..f67452ecc 100644
--- a/tests/tgamma.c
+++ b/tests/tgamma.c
@@ -438,7 +438,6 @@ gamma_integer (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/tget_f.c b/tests/tget_f.c
index 795fe570a..ee41b25c7 100644
--- a/tests/tget_f.c
+++ b/tests/tget_f.c
@@ -100,7 +100,6 @@ main (void)
mp_exp_t e;
int inex;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
mpfr_init (y);
diff --git a/tests/tli2.c b/tests/tli2.c
index 5444e5131..3ad4e1055 100644
--- a/tests/tli2.c
+++ b/tests/tli2.c
@@ -115,7 +115,6 @@ normal (void)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/tmul.c b/tests/tmul.c
index 1495bcfe9..f44445f14 100644
--- a/tests/tmul.c
+++ b/tests/tmul.c
@@ -658,7 +658,6 @@ mpfr_mulpi (mpfr_t y, mpfr_t x, mp_rnd_t r)
int
main (int argc, char *argv[])
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_nans ();
diff --git a/tests/tmul_d.c b/tests/tmul_d.c
index 4cff6eb5a..ff32c3407 100644
--- a/tests/tmul_d.c
+++ b/tests/tmul_d.c
@@ -70,7 +70,7 @@ main (int argc, char *argv[])
mpfr_t x, y, z;
double d;
int inexact;
- MPFR_TEST_USE_RANDS ();
+
tests_start_mpfr ();
/* check with enough precision */
diff --git a/tests/tmul_ui.c b/tests/tmul_ui.c
index b4b8d118d..07f6c59a5 100644
--- a/tests/tmul_ui.c
+++ b/tests/tmul_ui.c
@@ -88,7 +88,6 @@ main (int argc, char *argv[])
mp_prec_t p;
mp_exp_t emax;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
for (p=2; p<100; p++)
diff --git a/tests/tpow.c b/tests/tpow.c
index b2b1970e8..47a70a36f 100644
--- a/tests/tpow.c
+++ b/tests/tpow.c
@@ -1106,7 +1106,6 @@ main (void)
{
mp_prec_t p;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/tpow_z.c b/tests/tpow_z.c
index 16050ff0d..20beb97bb 100644
--- a/tests/tpow_z.c
+++ b/tests/tpow_z.c
@@ -22,6 +22,7 @@ MA 02110-1301, USA. */
#include <stdlib.h>
#include <float.h>
+#include <time.h>
#include <math.h>
#include "mpfr-test.h"
@@ -146,6 +147,10 @@ check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max)
mp_prec_t p;
int res1, res2;
mp_rnd_t rnd;
+ gmp_randstate_t state;
+
+ gmp_randinit (state, GMP_RAND_ALG_LC, 128);
+ gmp_randseed_ui (state, time(NULL));
mpfr_inits2 (begin, x, y1, y2, (void *) 0);
mpz_init (z);
@@ -156,7 +161,9 @@ check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max)
mpfr_set_prec (y2, p);
for (i = 0 ; i < max ; i++)
{
- mpz_random (z, (i&1) == 0 ? -1 : 1);
+ mpz_urandomb (z, state, GMP_NUMB_BITS);
+ if ((i & 1) != 0)
+ mpz_neg (z, z);
mpfr_random (x);
mpfr_mul_2ui (x, x, 1, GMP_RNDN); /* 0 <= x < 2 */
rnd = (mp_rnd_t) RND_RAND ();
@@ -189,6 +196,7 @@ check_integer (mp_prec_t begin, mp_prec_t end, unsigned long max)
} /* for i */
} /* for p */
mpfr_clears (x, y1, y2, (void *) 0);
+ gmp_randclear (state);
mpz_clear (z);
}
@@ -257,7 +265,6 @@ bug20071104 (void)
int
main (void)
{
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_special ();
diff --git a/tests/trandom.c b/tests/trandom.c
index 88a74c30b..cbdfa26d7 100644
--- a/tests/trandom.c
+++ b/tests/trandom.c
@@ -263,7 +263,6 @@ main (int argc, char *argv[])
mp_prec_t prec;
int verbose = 0;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
if (argc > 1)
diff --git a/tests/troot.c b/tests/troot.c
index cbc6bf267..aa08a044d 100644
--- a/tests/troot.c
+++ b/tests/troot.c
@@ -268,7 +268,6 @@ main (void)
mp_prec_t p;
unsigned long k;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
special ();
diff --git a/tests/tset_f.c b/tests/tset_f.c
index f7f43bcc5..b5112521e 100644
--- a/tests/tset_f.c
+++ b/tests/tset_f.c
@@ -35,8 +35,8 @@ main (void)
mp_exp_t emax;
unsigned long k, pr;
int r, inexact;
+ gmp_randstate_t state;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
mpf_init (y);
@@ -49,7 +49,9 @@ main (void)
mpfr_set_prec (x, 100);
mpfr_set_f (x, y, GMP_RNDN);
- mpf_random2 (y, 10, 0);
+ gmp_randinit (state, GMP_RAND_ALG_LC, 128);
+ gmp_randseed_ui (state, time(NULL));
+ mpf_urandomb (y, state, 10 * GMP_NUMB_BITS);
mpfr_set_f (x, y, (mp_rnd_t) RND_RAND());
/* bug found by Jean-Pierre Merlet */
@@ -94,7 +96,7 @@ main (void)
{
pr = 2 + (randlimb () & 255);
mpf_set_prec (z, pr);
- mpf_random2 (z, z->_mp_prec, 0);
+ mpf_urandomb (z, state, z->_mp_prec);
mpfr_set_prec (x, pr);
mpfr_set_f (x, z, (mp_rnd_t) 0);
}
@@ -177,6 +179,7 @@ main (void)
mpfr_clear (u);
mpf_clear (y);
mpf_clear (z);
+ gmp_randclear (state);
tests_end_mpfr ();
return 0;
diff --git a/tests/tsi_op.c b/tests/tsi_op.c
index 3fbe72e34..6e60a3473 100644
--- a/tests/tsi_op.c
+++ b/tests/tsi_op.c
@@ -101,7 +101,6 @@ main (int argc, char *argv[])
int y;
int i;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
mpfr_inits2 (53, x, z, (void *) 0);
for(i = 0 ; i < numberof (tab) ; i++)
diff --git a/tests/tsub.c b/tests/tsub.c
index ce64143f4..d91d806a2 100644
--- a/tests/tsub.c
+++ b/tests/tsub.c
@@ -482,7 +482,6 @@ main (void)
mp_prec_t p;
unsigned int i;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_diverse ();
diff --git a/tests/tsub_d.c b/tests/tsub_d.c
index f786ae900..98253b5e7 100644
--- a/tests/tsub_d.c
+++ b/tests/tsub_d.c
@@ -66,7 +66,6 @@ main (int argc, char *argv[])
mpfr_t x, y, z;
double d;
int inexact;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
/* check with enough precision */
diff --git a/tests/tsub_ui.c b/tests/tsub_ui.c
index 14cba1eb3..6ea9f852e 100644
--- a/tests/tsub_ui.c
+++ b/tests/tsub_ui.c
@@ -126,7 +126,6 @@ main (int argc, char *argv[])
mp_prec_t p;
int k;
- MPFR_TEST_USE_RANDS ();
tests_start_mpfr ();
check_nans ();