x is an array of characters. i is the bit index. since each char is 8 bits, the last 3 bits of i determine the bit in char, and the remaining bits define char in the array.
i>>3 shift i 3 bits to the right, so you get the part that tells you that char, so x[i>>3] is a char that contains the bit indexed i .
i&7 is the last 3 bits of i (since 7 10 ==111 2 ), so this is the bit index in char. 1<<(i&7) is a char (this is truly an int, but in this context you can ignore the difference), which has a bit indexed by i on and the rest of the bits are off. (mask bit)
char&mask is a common way to check if a bit is enabled.
char|=mask is the usual way to enable bits.
char&=~mask is the usual way to disable the bit, and if mask is char, then ~mask==mask^0xFF .
I do not think these macros are endiannes dependent. (if you got x by converting int[] to *char , this is a different story)
source share