[libvirt] FreeBSD, no gcc present libvirt build issue

Eric Blake eblake at redhat.com
Thu Aug 29 16:42:23 UTC 2013


On 08/29/2013 10:33 AM, Eric Blake wrote:
>> Since gnulib has a working random_r() function can we just make
>> gnulib replace the boneheaded freebsd impl ?
> 
> Huh - the glibc man pages state that random_r returns RAND_MAX bits.
> random_r is a glibc extension: POSIX only requires rand(), rand_r(), and
> random(); but even with random(), POSIX has no requirements that it be
> related to RAND_MAX - so the fact that glibc equates random()/random_r()
> with RAND_MAX is also a glibc extension.
> 
> I guess that means we should't be worrying about RAND_MAX in the first
> place, as it is tied to the (potentially algorithmically weaker) rand(),
> and need not have any bearing on the fact that we already use gnulib's
> random_r().
> 
> I'll play around with a patch.

As it is, POSIX recommends the use of drand48() and friends for
multithreaded apps, not random() (where lrand48() would match precisely
with a RAND_MAX of 0x7fffffff); but that's because POSIX lacks
random_r().  But since gnulib lacks [dl]rand48(), I still think libvirt
is still better off sticking with random_r(), and just avoiding the red
herring of a potentially unrelated RAND_MAX.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 621 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20130829/92855833/attachment-0001.sig>


More information about the libvir-list mailing list