From owner-svn-src-all@FreeBSD.ORG Fri Feb 27 08:23:10 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 7709DE8E; Fri, 27 Feb 2015 08:23:10 +0000 (UTC) Received: from kif.fubar.geek.nz (kif.fubar.geek.nz [178.62.119.249]) by mx1.freebsd.org (Postfix) with ESMTP id 425357C4; Fri, 27 Feb 2015 08:23:09 +0000 (UTC) Received: from bender.Home (97e64d4c.skybroadband.com [151.230.77.76]) by kif.fubar.geek.nz (Postfix) with ESMTPSA id 3C39AD79EC; Fri, 27 Feb 2015 08:23:03 +0000 (UTC) Date: Fri, 27 Feb 2015 08:22:57 +0000 From: Andrew Turner To: Warner Losh Subject: Re: svn commit: r279349 - head/sys/kern Message-ID: <20150227082257.3fb1081c@bender.Home> In-Reply-To: <201502270256.t1R2uxnv085328@svn.freebsd.org> References: <201502270256.t1R2uxnv085328@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2015 08:23:10 -0000 On Fri, 27 Feb 2015 02:56:59 +0000 (UTC) Warner Losh wrote: ... > /* > + * We need some randomness. Implement the classic Linear Congruential > + * generator X_{n+1}=(aX_n+c) mod m. These values are optimized for > + * m = 2^32, a = 69069 and c = 5. This is signed so that we can get > + * both positive and negative values from it by shifting the value > + * right. > + */ > +static int sched_random() > +{ > + int rnd, *rndptr; > + rndptr = DPCPU_PTR(randomval); > + rnd = *rndptr * 69069 + 5; > + *rndptr = rnd; > + return(rnd); > +} Didn't we recently have issues with signed integer overflow being undefined? Even though we worked around it with a compiler flag it would be better to not rely on undefined behaviour in the first place. Andrew