[PATCH evdev] type-safe inline functions for bitmask manipulation

Peter Hutterer peter.hutterer at who-t.net
Tue Oct 18 17:44:15 PDT 2011


On Mon, Oct 17, 2011 at 08:24:48PM +0200, Max Schwarz wrote:
> > Have you looked into switching the evdev bit arrays from longs to bytes
> > so we can standardize on one type of bit array?
> That would be possible. Longs are used because the linux evdev layer uses 
> longs and we can let ioctl() write directly into our bitmask arrays. I can 
> change the occurences of ioctl() to use a temporary buffer and fix the byte 
> order if necessary.

here's the thing that's confusing me: why does the byte order matter?
All the bits are just bits. (1 << KEY_FOO) is the same bit regardless of
endianess.

BitIsOn(ptr, KEY_A):            ((BYTE*)ptr)[3] & (1 << 6)
EvdevBitIsSet(array, KEY_A):    array[0] & (1 << 30)

same thing, right? what am I missing here? AFAICT we can just pump the long
array into TestBit and everything is hunky-dory anyway.

Cheers,
  Peter


More information about the xorg-devel mailing list