On 11/20/2013 01:04 PM, Andrea Mazzoleni wrote:
> Hi Peter,
> 
>>> static inline uint64_t d2_64(uint64_t v)
>>> {
>>>         uint64_t mask = v & 0x0101010101010101U;
>>>         mask = (mask << 8) - mask;
>>
>> (mask << 7) I assume...
> No. It's "(mask << 8) - mask". We want to expand the bit at position 0
> (in each byte) to the full byte, resulting in 0xFF if the bit is at 1,
> and 0x00 if the bit is 0.
> 
> (0 << 8) - 0 = 0x00
> (1 << 8) - 1 = 0x100 - 1 = 0xFF
> 

Oh, right... it is the same as (v << 1) - (v >> 7) except everything is
shifted over one.

        -hpa


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to