[BACK]Return to urandom.h CVS log [TXT][DIR] Up to [local] / OpenXM / src / kan96xx / gmp-2.0.2-ssh-2

Annotation of OpenXM/src/kan96xx/gmp-2.0.2-ssh-2/urandom.h, Revision 1.1.1.1

1.1       takayama    1: /* urandom.h -- define urandom returning a full unsigned long random value.
                      2:
                      3: Copyright (C) 1995, 1996 Free Software Foundation, Inc.
                      4:
                      5: This file is part of the GNU MP Library.
                      6:
                      7: The GNU MP Library is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU Library General Public License as published by
                      9: the Free Software Foundation; either version 2 of the License, or (at your
                     10: option) any later version.
                     11:
                     12: The GNU MP Library is distributed in the hope that it will be useful, but
                     13: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     14: or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
                     15: License for more details.
                     16:
                     17: You should have received a copy of the GNU Library General Public License
                     18: along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
                     19: the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
                     20: MA 02111-1307, USA. */
                     21:
                     22: #if BITS_PER_MP_LIMB == 32 && !defined (__URANDOM)
                     23: long random ();
                     24: static inline unsigned long
                     25: urandom ()
                     26: {
                     27:   /* random() returns 31 bits, we want 32.  */
                     28:   return random () ^ (random () << 1);
                     29: }
                     30: #define __URANDOM
                     31: #endif
                     32:
                     33: #if BITS_PER_MP_LIMB == 64 && !defined (__URANDOM)
                     34: long random ();
                     35: #ifdef _LONG_LONG_LIMB
                     36: static inline unsigned long long
                     37: urandom ()
                     38: {
                     39:   /* random() returns 31 bits, we want 64.  */
                     40:   return (unsigned long long) random () ^
                     41:     ((unsigned long long) random () << 31) ^
                     42:     ((unsigned long long) random () << 62);
                     43: }
                     44: #else
                     45: static inline unsigned long
                     46: urandom ()
                     47: {
                     48:   /* random() returns 31 bits, we want 64.  */
                     49:   return random () ^ (random () << 31) ^ (random () << 62);
                     50: }
                     51: #endif /* _LONG_LONG_LIMB */
                     52: #define __URANDOM
                     53: #endif

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