qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] Re: [PATCH 1/7] qcow2: Make get_bits_from_size() common


From: Paolo Bonzini
Subject: [Qemu-devel] Re: [PATCH 1/7] qcow2: Make get_bits_from_size() common
Date: Fri, 24 Sep 2010 14:56:29 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100907 Fedora/3.1.3-1.fc13 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.3

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.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]