rustyrussell / ccan

The C Code Archive Network
http://ccodearchive.net/
1.11k stars 206 forks source link

bitmap doesn't work on 32bit x86/ARM #80

Closed PengZheng closed 5 years ago

PengZheng commented 5 years ago

bitmap_zero_range/bitmap_fill_range/bitmap_ffs doesn't work on 32bit platform, since long long is 64 bit while long is 32 bit. The build-in tests simply failed.

@dgibson @rustyrussell The fix is straight forward:

change from

    bitmap_word headmask = -1ULL >> (n % BITMAP_WORD_BITS);
    bitmap_word tailmask = ~(-1ULL >> (m % BITMAP_WORD_BITS));

to

    bitmap_word headmask = -1UL >> (n % BITMAP_WORD_BITS);
    bitmap_word tailmask = ~(-1UL >> (m % BITMAP_WORD_BITS));
dgibson commented 5 years ago

Ah, yes, nice catch.

Weirdly github is doing something strange here - in the web ui your suggested change is clear enough. In the mail it sent me, it's formatted it as a patch... but gotten it the wrong way around, so it's suggesting changing it from your fixed version to what it is now.

I'd actually like to make this change slightly differently, let me see what I can do.

dgibson commented 5 years ago

Ok, I think I've now fixed this in master.