X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/90186c68a4616d7e55617f46495bfc2f1059ff7f..f0fcdf4bf698f58127f56c207db4f2ac02df17ad:/src/fns.c diff --git a/src/fns.c b/src/fns.c index 5d2524d5cc..0ca731ed33 100644 --- a/src/fns.c +++ b/src/fns.c @@ -79,10 +79,14 @@ Other values of LIMIT are ignored. */) { EMACS_INT val; Lisp_Object lispy_val; - EMACS_UINT denominator; if (EQ (limit, Qt)) - seed_random (getpid () + time (NULL)); + { + EMACS_TIME t; + EMACS_GET_TIME (t); + seed_random (getpid () ^ EMACS_SECS (t) ^ EMACS_USECS (t)); + } + if (NATNUMP (limit) && XFASTINT (limit) != 0) { /* Try to take our random number from the higher bits of VAL, @@ -92,7 +96,7 @@ Other values of LIMIT are ignored. */) it's possible to get a quotient larger than n; discarding these values eliminates the bias that would otherwise appear when using a large n. */ - denominator = ((EMACS_UINT) 1 << VALBITS) / XFASTINT (limit); + EMACS_INT denominator = (INTMASK + 1) / XFASTINT (limit); do val = get_random () / denominator; while (val >= XFASTINT (limit));