summaryrefslogtreecommitdiff
path: root/tests/misc.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-03-03 00:36:25 +0100
committerKevin Ryde <user42@zip.com.au>2001-03-03 00:36:25 +0100
commitb2549a90f5aa0a1663bd9cca9057b126340cb3bf (patch)
treef838fb77df9b358a27defaa871010d19708ea44d /tests/misc.c
parent7185117b7feeecb7f1987f6d5b0babaa47504f88 (diff)
downloadgmp-b2549a90f5aa0a1663bd9cca9057b126340cb3bf.tar.gz
More of:
* tests/misc.c (tests_rand_start, tests_rand_end): New functions.
Diffstat (limited to 'tests/misc.c')
-rw-r--r--tests/misc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/misc.c b/tests/misc.c
index 9f8f0c151..d75036fec 100644
--- a/tests/misc.c
+++ b/tests/misc.c
@@ -60,29 +60,37 @@ tests_end (void)
void
tests_rand_start (void)
{
+ gmp_randstate_ptr rands;
char *perform_seed;
unsigned long seed;
+ if (__gmp_rands_initialized)
+ {
+ printf ("Please let tests_start() initialize the global __gmp_rands.\n");
+ printf ("ie. ensure that function is called before the first use of RANDS.\n");
+ abort ();
+ }
+ rands = RANDS;
+
perform_seed = getenv ("GMP_CHECK_RANDOMIZE");
if (perform_seed != NULL)
{
seed = atoi (perform_seed);
if (! (seed == 0 || seed == 1))
{
- printf ("GMP_CHECK_RANDOMIZE re-seeding with %ld\n", seed);
- gmp_randseed_ui (RANDS, seed);
+ printf ("GMP_CHECK_RANDOMIZE re-seeding with %lu\n", seed);
+ gmp_randseed_ui (rands, seed);
}
else
{
#if HAVE_GETTIMEOFDAY
struct timeval tv;
gettimeofday (&tv, NULL);
- gmp_randseed_ui (RANDS, tv.tv_sec + tv.tv_usec);
- printf ("PLEASE INCLUDE THIS SEED NUMBER IN ALL BUG REPORTS:\n");
- printf ("GMP_CHECK_RANDOMIZE is set--seeding with %ld\n",
- tv.tv_sec + tv.tv_usec);
+ seed = tv.tv_sec + tv.tv_usec;
+ gmp_randseed_ui (rands, seed);
+ printf ("GMP_CHECK_RANDOMIZE seed %lu (include this in bug reports)\n", seed);
#else
- printf ("Oops, gettimeofday() not available, use something else\n");
+ printf ("tests_rand_start(): Oops, gettimeofday() not available\n");
abort ();
#endif
}