From owner-cvs-all Sun Feb 25 10:59: 9 2001 Delivered-To: cvs-all@freebsd.org Received: from gw.nectar.com (gw.nectar.com [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id 9DF6E37B4EC; Sun, 25 Feb 2001 10:59:02 -0800 (PST) (envelope-from nectar@nectar.com) Received: from hamlet.nectar.com (hamlet.nectar.com [10.0.1.102]) by gw.nectar.com (Postfix) with ESMTP id 86AE318C91; Sun, 25 Feb 2001 12:59:01 -0600 (CST) Received: (from nectar@localhost) by hamlet.nectar.com (8.11.2/8.9.3) id f1PIx1o47174; Sun, 25 Feb 2001 12:59:01 -0600 (CST) (envelope-from nectar@spawn.nectar.com) Date: Sun, 25 Feb 2001 12:59:01 -0600 From: "Jacques A. Vidrine" To: "Andrey A. Chernov" Cc: Mark Murray , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: rand.c patch for review (was: Re: cvs commit: ports/astro/xglobe/files patch-random) Message-ID: <20010225125901.A47165@hamlet.nectar.com> Mail-Followup-To: "Jacques A. Vidrine" , "Andrey A. Chernov" , Mark Murray , cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org References: <20010225193409.A56351@nagual.pp.ru> <200102251758.f1PHwuR02481@gratis.grondar.za> <20010225213744.A57744@nagual.pp.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <20010225213744.A57744@nagual.pp.ru>; from ache@nagual.pp.ru on Sun, Feb 25, 2001 at 09:37:44PM +0300 X-Url: http://www.nectar.com/ Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Feb 25, 2001 at 09:37:44PM +0300, Andrey A. Chernov wrote: > On Sun, Feb 25, 2001 at 19:59:41 +0200, Mark Murray wrote: > > > Patch for review: > > > > Whats wrong with > > > > int > > rand(void) > > { > > return((int)random()); > > } > > > > ?? > > 1) Seed & State. Even if srand() is backed by srandom(), if called > independently, they overwrite each other seeding > state. initstate() etc. adds more here. Emphasis: Standard C says that rand/srand must behave as if no other library functions ever call them. i.e. the state must not change except when the application calls rand/srand. Cheers, -- Jacques Vidrine / n@nectar.com / jvidrine@verio.net / nectar@FreeBSD.org To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message