From owner-freebsd-hackers Thu Dec 14 22:54:49 2000 From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 14 22:54:47 2000 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from citusc.usc.edu (citusc.usc.edu [128.125.38.123]) by hub.freebsd.org (Postfix) with ESMTP id 3B13B37B400 for ; Thu, 14 Dec 2000 22:54:47 -0800 (PST) Received: (from kris@localhost) by citusc.usc.edu (8.9.3/8.9.3) id WAA02703; Thu, 14 Dec 2000 22:56:00 -0800 Date: Thu, 14 Dec 2000 22:56:00 -0800 From: Kris Kennaway To: Peter Jeremy Cc: hackers@FreeBSD.ORG, sheldonh@uunet.co.za, arnold@skeeve.com Subject: Re: BSD random for Alpha? Message-ID: <20001214225600.F2040@citusc.usc.edu> References: <20001204092348.A92196@gsmx07.alcatel.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20001204092348.A92196@gsmx07.alcatel.com.au>; from peter.jeremy@alcatel.com.au on Mon, Dec 04, 2000 at 09:23:48AM +1100 Sender: kris@citusc.usc.edu Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, Dec 04, 2000 at 09:23:48AM +1100, Peter Jeremy wrote: > >Hi. I've switched to the new random.c you sent me for gawk. My > >Linux/Alpha Guru reports that the code in it assumes that sizeof(long) > >is always 4, and one particular test doesn't "look" very random on > >the Alpha. > > > >My question is, is there a better version of random that can deal > >with both 32 and 64 bit systems in the same source code? Would > >the NetBSD people maybe have such a thing? > > Try a Fibonacci-sequence random number generator (they're mentioned > in Knuth). The general form is: > > X[n] = (X[n-j] + X[n-k]) mod m I think this would be bad - for a general-purpose language like awk we should be using a cryptographic-strength PRNG like arc4random() or /dev/urandom so that people can use it for any purpose. 64-bit cleanliness can presumably be taken care of easily enough. Kris To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message