[BACK]Return to random.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp / mpn / generic

Diff for /OpenXM_contrib/gmp/mpn/generic/Attic/random.c between version 1.1 and 1.1.1.2

version 1.1, 2000/09/09 14:12:27 version 1.1.1.2, 2003/08/25 16:06:20
Line 1 
Line 1 
 /* mpn_random -- Generate random numbers.  /* 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.  This file is part of the GNU MP Library.
   
Line 21  MA 02111-1307, USA. */
Line 21  MA 02111-1307, USA. */
   
 #include "gmp.h"  #include "gmp.h"
 #include "gmp-impl.h"  #include "gmp-impl.h"
 #include "urandom.h"  
   
 void  void
 #if __STDC__  mpn_random (mp_ptr ptr, mp_size_t size)
 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  
 {  {
   mp_size_t i;    gmp_randstate_ptr  rands;
   
   for (i = 0; i < size; i++)    /* FIXME: Is size==0 supposed to be allowed? */
     res_ptr[i] = urandom ();    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.  */    /* Make sure the most significant limb is non-zero.  */
   while (res_ptr[size - 1] == 0)    while (ptr[size-1] == 0)
     res_ptr[size - 1] = urandom ();      _gmp_rand (&ptr[size-1], rands, GMP_NUMB_BITS);
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.1.2

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>