From owner-freebsd-current Sun Feb 2 14:13: 2 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 409C837B401 for ; Sun, 2 Feb 2003 14:13:00 -0800 (PST) Received: from storm.FreeBSD.org.uk (storm.FreeBSD.org.uk [194.242.157.42]) by mx1.FreeBSD.org (Postfix) with ESMTP id 564E143F43 for ; Sun, 2 Feb 2003 14:12:59 -0800 (PST) (envelope-from mark@grondar.org) Received: from storm.FreeBSD.org.uk (Ugrondar@localhost [127.0.0.1]) by storm.FreeBSD.org.uk (8.12.6/8.12.6) with ESMTP id h12MBtLf080732; Sun, 2 Feb 2003 22:11:55 GMT (envelope-from mark@grondar.org) Received: (from Ugrondar@localhost) by storm.FreeBSD.org.uk (8.12.6/8.12.6/Submit) with UUCP id h12MBsgk080731; Sun, 2 Feb 2003 22:11:54 GMT X-Authentication-Warning: storm.FreeBSD.org.uk: Ugrondar set sender to mark@grondar.org using -f Received: from grondar.org (localhost [127.0.0.1]) by grimreaper.grondar.org (8.12.6/8.12.6) with ESMTP id h12M9caX052345; Mon, 3 Feb 2003 00:09:39 +0200 (SAST) (envelope-from mark@grondar.org) From: Mark Murray Message-Id: <200302022209.h12M9caX052345@grimreaper.grondar.org> To: Bakul Shah Cc: current@FreeBSD.ORG Subject: Re: rand() is broken In-Reply-To: Your message of "Sun, 02 Feb 2003 13:59:25 PST." <200302022159.QAA13933@wellington.cnchost.com> Date: Sun, 02 Feb 2003 22:09:38 +0000 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Bakul Shah writes: > > No. Evil interface change. #ifdef hell while programs try to > > figure out OS differences. > > How so? This or a similar change is upward compatible in > that the existing behavior is left unchanged and it gives you > a way to replace the algorithm. It requies that programmers know about evil localisms. It screws over portability of source code. > The basic issue is just what is the expected and (implicitly) > promised behavior of random(). You believe one implied output. Another programmer believes another. Only way out is to make the routine "honest". > AFAIK all random(3) implementations in various versions of > Unix come from Earl's original 4.2BSD implementation so in my > view the _expected_ behavior is to see the _exact_ same > sequence starting from a given seed. This function is called > "random()" but it is equivalent to a mathematical function > which must provide the same sequence for the exact same > input. Maybe that is the greatgrandfather. The grandchildren speak with different accents now. :-) > You and a number of other people are saying that the exact > sequence is *not* promised so you are free to change the > algortithm as long as the statistical distribution is > uniform. Not quite. Close. You compile program on a machine with a constant argument to srand[om](). Run the more than once, and rand[om]() will give you the same sequence. Another OS, another time, another version of libc, the sequence will again be constant, but different from last time. > Earl chose to name his new implementation random() [even > though clearly he was replacing rand(3)] probably to not > break any existing scripts. In my view any further behavior > change should either use a new name or make an upward > compatible change. You have said that before, and I understand your words. I disagree with them. > Now the question is whether perl uses system provided > random() or rand() or its own since perl is used extensively > in ASIC verification. Different question. Ask the perl developers. M -- Mark Murray iumop ap!sdn w,I idlaH To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message