=================================================================== RCS file: /home/cvs/OpenXM_contrib/gmp/mpf/Attic/urandomb.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/mpf/Attic/urandomb.c 2000/09/09 14:13:15 1.1.1.1 +++ OpenXM_contrib/gmp/mpf/Attic/urandomb.c 2003/08/25 16:06:35 1.1.1.2 @@ -3,7 +3,7 @@ using STATE as the random state previously initialized by a call to gmp_randinit(). -Copyright (C) 1999, 2000 Free Software Foundation, Inc. +Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. This file is part of the GNU MP Library. @@ -26,30 +26,24 @@ MA 02111-1307, USA. */ #include "gmp-impl.h" void -#if __STDC__ mpf_urandomb (mpf_t rop, gmp_randstate_t rstate, unsigned long int nbits) -#else -mpf_urandomb (rop, rstate, nbits) - mpf_t rop; - gmp_randstate_t rstate; - unsigned long int nbits; -#endif { mp_ptr rp; mp_size_t nlimbs; mp_exp_t exp; + nbits = MIN (nbits, __GMPF_PREC_TO_BITS (rop->_mp_prec)); + rp = PTR (rop); - nlimbs = (nbits + BITS_PER_MP_LIMB - 1) / BITS_PER_MP_LIMB; + nlimbs = (nbits + GMP_NUMB_BITS - 1) / GMP_NUMB_BITS; _gmp_rand (rp, rstate, nbits); - /* If nbits isn't a multiple of BITS_PER_MP_LIMB, shift up. */ + /* If nbits isn't a multiple of GMP_NUMB_BITS, shift up. */ if (nlimbs != 0) { - if (nbits % BITS_PER_MP_LIMB != 0) - mpn_lshift (rp, rp, nlimbs, - BITS_PER_MP_LIMB - nbits % BITS_PER_MP_LIMB); + if (nbits % GMP_NUMB_BITS != 0) + mpn_lshift (rp, rp, nlimbs, GMP_NUMB_BITS - nbits % GMP_NUMB_BITS); } exp = 0; @@ -60,5 +54,4 @@ mpf_urandomb (rop, rstate, nbits) } EXP (rop) = exp; SIZ (rop) = nlimbs; - }