From owner-svn-src-head@freebsd.org Sun May 22 02:54:33 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27C91B3B154 for ; Sun, 22 May 2016 02:54:33 +0000 (UTC) (envelope-from pfg@freebsd.org) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1.freebsd.org (Postfix) with SMTP id 0DFC91BA6 for ; Sun, 22 May 2016 02:54:32 +0000 (UTC) (envelope-from pfg@freebsd.org) Received: (qmail 63232 invoked by uid 99); 22 May 2016 02:54:26 -0000 Received: from mail-relay.apache.org (HELO mail-relay.apache.org) (140.211.11.15) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 22 May 2016 02:54:26 +0000 Received: from [192.168.0.100] (unknown [181.55.232.163]) by mail-relay.apache.org (ASF Mail Server at mail-relay.apache.org) with ESMTPSA id D2BB31A0118; Sun, 22 May 2016 02:54:24 +0000 (UTC) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) Subject: Re: svn commit: r300384 - head/sys/compat/ndis From: Pedro Giffuni In-Reply-To: <20160522112323.N1388@besplex.bde.org> Date: Sat, 21 May 2016 21:54:22 -0500 Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Transfer-Encoding: quoted-printable Message-Id: <214223B1-89C7-403B-84F1-8F9B539D29C5@freebsd.org> References: <201605220029.u4M0TPI6050123@repo.freebsd.org> <20160522112323.N1388@besplex.bde.org> To: Bruce Evans X-Mailer: Apple Mail (2.2104) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 22 May 2016 02:54:33 -0000 > Il giorno 21/mag/2016, alle ore 21:15, Bruce Evans = ha scritto: >=20 > On Sun, 22 May 2016, Pedro F. Giffuni wrote: >=20 >> Log: >> ndis(4): adjustments for our random() specific implementation. >>=20 >> - Revert r300377: The implementation claims to return a value >> within the range. [1] >> - Adjust the value for the case of a zero seed, whihc according >> to standards should be equivalent to a seed of value 1. >=20 > This was already correct. Standards don't say that a seed of 0 for > srand() means the same as a seed of 1 passed to srand(). They say > that if srand() is not called, then the sequence shall be the same > as if it had been called with a seed of 1. This is already > implemented by using an internal initial value of the seed that is > the result of srand(1). >=20 OK. I misunderstood the standard. I will revert the if seed thing. (Tomorrow). > The commit gives the following bugs: > - srand() is less random. srand(0) now gives the same sequence as > srand(0) > - srand(0) is not binary compatible. >=20 > My previous mail pointed out the version in libc is the kernel version > with some bugs fixed. It also has some regressions. In the libc > version, srand(seed) sets the internal seed almost directly (it just > adds 1 for technical reasons). The kernel version advances the seed > through 50 iterations of random(). This doesn't really increase > randomness but it makes the linearity relation in the LCG less = obvious. >=20 Merging both is out of scope from what I expected to be a much simpler cleanup for ndis(4). I would have liked to replace completely random() with something like Mersenne Twister + unpredictable seed but that is basically a waste of time: developers seem sufficiently happy with random() and when not arc4random() can be used. :-/ Thanks for all this feedback. Pedro. >=20