# HG changeset patch # User Karl Heuer # Date 790558603 0 # Node ID 40c59e55775ac2fd3a2a492da739843d24f8f628 # Parent 08e1b7f85e5e6c6e04fec1272eafe0c3a90cc45c (Frandom): Call seed_random and get_random. diff -r 08e1b7f85e5e -r 40c59e55775a src/fns.c --- a/src/fns.c Thu Jan 19 22:24:43 1995 +0000 +++ b/src/fns.c Thu Jan 19 23:36:43 1995 +0000 @@ -47,23 +47,24 @@ return arg; } +extern long get_random (); +extern void seed_random (); +extern long time (); + DEFUN ("random", Frandom, Srandom, 0, 1, 0, "Return a pseudo-random number.\n\ All integers representable in Lisp are equally likely.\n\ On most systems, this is 28 bits' worth.\n\ -With argument N, return random number in interval [0,N).\n\ +With positive integer argument N, return random number in interval [0,N).\n\ With argument t, set the random number seed from the current time and pid.") (limit) Lisp_Object limit; { int val; unsigned long denominator; - extern long random (); - extern srandom (); - extern long time (); if (EQ (limit, Qt)) - srandom (getpid () + time (0)); + seed_random (getpid () + time (0)); if (NATNUMP (limit) && XFASTINT (limit) != 0) { /* Try to take our random number from the higher bits of VAL, @@ -75,11 +76,11 @@ when using a large limit. */ denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit); do - val = (random () & (((unsigned long)1 << VALBITS) - 1)) / denominator; + val = get_random () / denominator; while (val >= XFASTINT (limit)); } else - val = random (); + val = get_random (); return make_number (val); }