From: Karl Heuer Date: Thu, 19 Jan 1995 23:36:43 +0000 (+0000) Subject: (Frandom): Call seed_random and get_random. X-Git-Tag: emacs-19.34~5373 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=99175c23d34107a2d4d7b1eb00d40b4c0d6704a3;p=emacs.git (Frandom): Call seed_random and get_random. --- diff --git a/src/fns.c b/src/fns.c index 71c7243d706..c17c62020a6 100644 --- a/src/fns.c +++ b/src/fns.c @@ -47,23 +47,24 @@ DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, 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 @@ With argument t, set the random number seed from the current time and pid.") 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); }