From owner-svn-src-head@freebsd.org Sun May 22 02:15:52 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 83392B436C9; Sun, 22 May 2016 02:15:52 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id 4F36B1450; Sun, 22 May 2016 02:15:52 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from c122-106-149-109.carlnfd1.nsw.optusnet.com.au (c122-106-149-109.carlnfd1.nsw.optusnet.com.au [122.106.149.109]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id 2FB56782F47; Sun, 22 May 2016 12:15:41 +1000 (AEST) Date: Sun, 22 May 2016 12:15:41 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: "Pedro F. Giffuni" cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300384 - head/sys/compat/ndis In-Reply-To: <201605220029.u4M0TPI6050123@repo.freebsd.org> Message-ID: <20160522112323.N1388@besplex.bde.org> References: <201605220029.u4M0TPI6050123@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=EfU1O6SC c=1 sm=1 tr=0 a=R/f3m204ZbWUO/0rwPSMPw==:117 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=E5bWiKrETEzLNUIpf3EA:9 a=CjuIK1q_8ugA:10 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:15:52 -0000 On Sun, 22 May 2016, Pedro F. Giffuni wrote: > Log: > ndis(4): adjustments for our random() specific implementation. > > - 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. 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). 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. 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. Bruce