[openib-general] Re: [PATCH] Fix ib_pack/unpack for 64 bits
Roland Dreier
roland at topspin.com
Thu Jun 23 09:26:37 PDT 2005
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?
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. I'll fix this up.
- R.
More information about the general
mailing list