[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Re: [PATCH 1/7] qcow2: Make get_bits_from_size() common
From: |
Stefan Hajnoczi |
Subject: |
Re: [Qemu-devel] Re: [PATCH 1/7] qcow2: Make get_bits_from_size() common |
Date: |
Fri, 24 Sep 2010 15:18:44 +0100 |
On Fri, Sep 24, 2010 at 1:56 PM, Paolo Bonzini <address@hidden> wrote:
> On 09/24/2010 10:37 AM, Stefan Hajnoczi wrote:
>>
>> On Fri, Sep 24, 2010 at 01:50:39AM +0400, malc wrote:
>>>
>>> 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.
>>
>> What is the situation with WIN64?
>
> long is only 32 bit, so you need __builtin_ctzll.
Thanks Paolo and malc. It should be easy enough to use the builtin instead.
Stefan
- [Qemu-devel] [PATCH 0/7] qed: Add QEMU Enhanced Disk format, Stefan Hajnoczi, 2010/09/23
- [Qemu-devel] [PATCH 3/7] cutils: qemu_iovec_copy and qemu_iovec_memset, Stefan Hajnoczi, 2010/09/23
- [Qemu-devel] [PATCH 7/7] qed: Consistency check support, Stefan Hajnoczi, 2010/09/23
- [Qemu-devel] [PATCH 5/7] qed: Table, L2 cache, and cluster functions, Stefan Hajnoczi, 2010/09/23
- [Qemu-devel] [PATCH 1/7] qcow2: Make get_bits_from_size() common, Stefan Hajnoczi, 2010/09/23
[Qemu-devel] [PATCH 2/7] cutils: Add bytes_to_str() to format byte values, Stefan Hajnoczi, 2010/09/23
[Qemu-devel] [PATCH 4/7] qed: Add QEMU Enhanced Disk image format, Stefan Hajnoczi, 2010/09/23
[Qemu-devel] [PATCH 6/7] qed: Read/write support, Stefan Hajnoczi, 2010/09/23
Re: [Qemu-devel] [PATCH 0/7] qed: Add QEMU Enhanced Disk format, Avi Kivity, 2010/09/27
Re: [Qemu-devel] [PATCH 0/7] qed: Add QEMU Enhanced Disk format, Avi Kivity, 2010/09/27