[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] FreeBSD, no gcc present libvirt build issue

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

Attachment: signature.asc
Description: OpenPGP digital signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]