Date: Thu, 29 Aug 2013 17:03:49 +0100 From: "Daniel P. Berrange" <berrange@redhat.com> To: Eric Blake <eblake@redhat.com> Cc: svn-src-head@freebsd.org, libvir-list <libvir-list@redhat.com>, Jason Helfman <jgh@freebsd.org> Subject: Re: [libvirt] FreeBSD, no gcc present libvirt build issue Message-ID: <20130829160349.GV14547@redhat.com> In-Reply-To: <521F6E54.1070104@redhat.com> References: <CAMuy=%2BiG20hs9b%2BD210=TZ50weyaJoPK8NZ8Mgea8s1A2UDQhw@mail.gmail.com> <521F63F4.4020406@redhat.com> <CAMuy=%2BhO15c_0EdjnMQMtL5OGESfQkkvjZ5oUwRGv2%2B0VB6U0w@mail.gmail.com> <CAMuy=%2BhgHARZyAUgiVaf0hdOSpTQOGRubucCY%2BQ6-kzDN8a5Ng@mail.gmail.com> <521F6C0F.9060007@redhat.com> <521F6E54.1070104@redhat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 :|
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130829160349.GV14547>