|
| From: | malc |
| Subject: | Re: [Qemu-devel] [PATCH 1/7] qcow2: Make get_bits_from_size() common |
| Date: | Fri, 24 Sep 2010 01:50:39 +0400 (MSD) |
| User-agent: | Alpine 2.00 (LNX 1167 2008-08-23) |
On Thu, 23 Sep 2010, Stefan Hajnoczi wrote:
> The get_bits_from_size() calculates the log base-2 of a number. This is
> useful in bit manipulation code working with power-of-2s.
>
> Currently used by qcow2 and needed by qed in a follow-on patch.
int ilog2 (size_t size)
{
if (size & (size - 1))
return -1;
return __builtin_ctzl (size);
}
Ifdef WIN64 omitted for brevity.
[..snip..]
--
mailto:address@hidden
| [Prev in Thread] | Current Thread | [Next in Thread] |