From owner-freebsd-arch Mon Feb 26 14:59:57 2001 Delivered-To: freebsd-arch@freebsd.org Received: from earth.backplane.com (earth-nat-cw.backplane.com [208.161.114.67]) by hub.freebsd.org (Postfix) with ESMTP id C520F37B401 for ; Mon, 26 Feb 2001 14:59:55 -0800 (PST) (envelope-from dillon@earth.backplane.com) Received: (from dillon@localhost) by earth.backplane.com (8.11.2/8.9.3) id f1QMxhP46130; Mon, 26 Feb 2001 14:59:43 -0800 (PST) (envelope-from dillon) Date: Mon, 26 Feb 2001 14:59:43 -0800 (PST) From: Matt Dillon Message-Id: <200102262259.f1QMxhP46130@earth.backplane.com> To: Kris Kennaway Cc: "Andrey A. Chernov" , "Jacques A. Vidrine" , arch@FreeBSD.ORG Subject: Re: rand.c patch for review (was: Re: cvs commit: ports/astro/xglobe/files patch-random) References: <20010225132152.A39554@mollari.cthul.hu> <20010226005004.B59772@nagual.pp.ru> <20010225135429.A47615@mollari.cthul.hu> <20010226020827.A61007@nagual.pp.ru> <20010225151519.A63582@mollari.cthul.hu> <20010226022902.A61216@nagual.pp.ru> <20010225173445.A37510@spawn.nectar.com> <20010226024456.A61566@nagual.pp.ru> <20010226174852.B435@ringworld.oblivion.bg> <20010226191008.A72434@nagual.pp.ru> <20010226142211.A20768@mollari.cthul.hu> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG :> random() (which is NOT original code). Practice says that nobody seriously :> want old behaviour. Moreover, standards (like SUSv2 f.e.) don't guarantee :> that the formula must be the same on different machines or even through :> different libc versions. It must be the same for single application run :> only, so in theory we can change formula for each application run :-) :>=20 :> So, I plan to skip this step as superfuous. You can't change the formula for each application run. One of the biggest reasons one specifies a seed is to ensure that the same random sequence will be produced across multiple program runs. Otherwise debugging can very difficult to impossible. Calling srandomdev() for random/srandom is a sufficient statement of intent to not want a reproducable sequence. calling srandom() is a sufficient statement of intent that you want a reproducable sequence. For rand() you don't have a choice. You only have srand() to call (and get a fixed seed of 1 if you don't). The specs imply that if you will get the same random sequence given the same seed. While we can change the algorithm between releases without creating too much dissention, we sure as hell can't change the algorithm for every process. The way I see it, we can only protect programmers against their own stupidity to a certain degree. We should not be wasting resources trying to make rand() perfect. It just needs to be able to do its jobs fairly well within the bounds of the API. -Matt To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message