Re: [PATCH] random: link with -lm when needed

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

 



On 08/14/2012 01:44 PM, Eric Blake wrote:

oops, hit send too soon

> Use of ldexp() requires -lm on some platforms; use gnulib to determine
> this for our makefile.  Also, optimize virRandomInt() for the case
> of a power-of-two limit (actually rather common, given that Daniel
> has a pending patch to replace virRandomBis(10) with code that will

s/Bis/Bits/

> default to virRandomInt(1024) on default SELinux settings).
> 

> @@ -135,6 +136,9 @@ double virRandom(void)
>   */
>  uint32_t virRandomInt(uint32_t max)
>  {
> +    if ((max & (max - 1)) == 0)
> +        return virRandomBits(ffs(max));

ffs(max)-1

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]