=================================================================== RCS file: /home/cvs/OpenXM_contrib/gmp/mpn/generic/Attic/random.c,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.2 diff -u -p -r1.1.1.1 -r1.1.1.2 --- OpenXM_contrib/gmp/mpn/generic/Attic/random.c 2000/09/09 14:12:27 1.1.1.1 +++ OpenXM_contrib/gmp/mpn/generic/Attic/random.c 2003/08/25 16:06:20 1.1.1.2 @@ -1,6 +1,6 @@ /* mpn_random -- Generate random numbers. -Copyright (C) 1996, 1997, 2000 Free Software Foundation, Inc. +Copyright 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -21,23 +21,22 @@ MA 02111-1307, USA. */ #include "gmp.h" #include "gmp-impl.h" -#include "urandom.h" void -#if __STDC__ -mpn_random (mp_ptr res_ptr, mp_size_t size) -#else -mpn_random (res_ptr, size) - mp_ptr res_ptr; - mp_size_t size; -#endif +mpn_random (mp_ptr ptr, mp_size_t size) { - mp_size_t i; + gmp_randstate_ptr rands; - for (i = 0; i < size; i++) - res_ptr[i] = urandom (); + /* FIXME: Is size==0 supposed to be allowed? */ + ASSERT (size >= 0); + if (size == 0) + return; + + rands = RANDS; + _gmp_rand (ptr, rands, size * GMP_NUMB_BITS); + /* Make sure the most significant limb is non-zero. */ - while (res_ptr[size - 1] == 0) - res_ptr[size - 1] = urandom (); + while (ptr[size-1] == 0) + _gmp_rand (&ptr[size-1], rands, GMP_NUMB_BITS); }