From owner-svn-src-head@FreeBSD.ORG Thu Aug 29 16:03:55 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id F3FAD1B9; Thu, 29 Aug 2013 16:03:54 +0000 (UTC) (envelope-from berrange@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx1.freebsd.org (Postfix) with ESMTP id B6355243A; Thu, 29 Aug 2013 16:03:54 +0000 (UTC) Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r7TG3qsM030774 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 29 Aug 2013 12:03:53 -0400 Received: from redhat.com (dhcp-1-155.lcy.redhat.com [10.32.224.155]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r7TG3neQ025181 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Thu, 29 Aug 2013 12:03:51 -0400 Date: Thu, 29 Aug 2013 17:03:49 +0100 From: "Daniel P. Berrange" To: Eric Blake Subject: Re: [libvirt] FreeBSD, no gcc present libvirt build issue Message-ID: <20130829160349.GV14547@redhat.com> References: <521F63F4.4020406@redhat.com> <521F6C0F.9060007@redhat.com> <521F6E54.1070104@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <521F6E54.1070104@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Cc: svn-src-head@freebsd.org, libvir-list , Jason Helfman X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: "Daniel P. Berrange" 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: Thu, 29 Aug 2013 16:03:55 -0000 On Thu, Aug 29, 2013 at 09:52:52AM -0600, Eric Blake wrote: > On 08/29/2013 09:43 AM, Eric Blake wrote: > > On 08/29/2013 09:35 AM, Jason Helfman wrote: > > > >>>> > >>> stdlib.h:#define RAND_MAX 0x7fffffff > > > > Good. > > > >>> > >>> -jgh > >>> > >> > >> And on our current head release (10) it is this: > >> > >> #define RAND_MAX 0x7ffffffd > > > > Huh? Why is this not 2**n-1? That violates assumptions we have made, > > and is WHY your compile failed. It has nothing to do with clang vs. gcc > > (both compilers would fail), it has to do with your changed system > > header resulting in violating assumptions that hold in ALL OTHER > > IMPLEMENTATIONS, that random numbers are evenly distributed within a > > range of a power of 2. > > > > http://lists.freebsd.org/pipermail/svn-src-head/2013-July/049076.html > > makes it look like the reduction in range was _intentional_? Yuck. A > non-power-of-2 random generator adds needless complexity to the user. > > I think I can fix libvirt to work around the boneheaded decision; > basically, since we cannot trust the full range of random_r to be evenly > distributed, I will have to tweak libvirt's call to truncate every call > to random_r to a subset of bits that are more likely to be evenly > distributed (maybe by shifting off the most- and least-significant bits > returned, and only using 28 instead of 31 bits of randomness per call). > But I would MUCH rather prefer that FreeBSD revisit their decision, and > guarantee that random output be evenly distributed across the full 31 > bits to begin with. Since gnulib has a working random_r() function can we just make gnulib replace the boneheaded freebsd impl ? > > I also intend to open a bug against POSIX to request that RAND_MAX be > required to be 2**n-1, rather than relying on the assumption that > everyone so far, until FreeBSD 10, has happened to meet that requirement. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|