[openib-general] Re: [PATCH] Fix ib_pack/unpack for 64 bits

Hal Rosenstock halr at voltaire.com
Thu Jun 23 09:40:28 PDT 2005


On Thu, 2005-06-23 at 12:26, Roland Dreier wrote:
>     Hal> It fixes 64 bit sizes (at least on 32 bit machines). The
>     Hal> problem was with the mask computation when size_bits = 64.
> 
>     Hal> mask = cpu_to_be64(((1ull << desc[i].size_bits) - 1) << shift);
> 
>     Hal> yielded a mask of 0 (for size_bits 64 and shift of 0). The 32
>     Hal> bit mask computation relies on the 33rd bit. In this case,
>     Hal> shifting the 1 64 bits does not put it in the 65th bit which
>     Hal> is needed for proper mask calculation.
> 
> Hmm, is there anywhere that actually sets size_bits to 64?

Not currently but hopefully soon.

> It's odd that you saw the expession end up as 0.  It seems that on every
> system I have, 1ull << 64 is 0, and 0 - 1 == -1 == 0xffffffffffffffff.
> So although it isn't correct C, it should work.
> 
> It is true that left shifting a 64-bit type by 64 bits is undefined
> according to standard C.

Maybe this is a compiler difference.

>   I'll fix this up.

Thanks.

-- Hal




More information about the general mailing list