Subject: Re: Bitfields and kernel
To: Brian C. Grayson <email@example.com>
From: Charles M. Hannum <firstname.lastname@example.org>
Date: 09/30/1999 16:22:58
> For setting multiple bits, using bitfields will work, and gcc optimizes
> it as tight as any hand-coded or (1<<30)|(1<<25) code -- into a
> single ori, in PowerPC-speak. I see no inherent reason why gcc
> can't do as good of a job optimizing bitfield manipulations as
> it can #define'd bitmask ops.
That depends somewhat on what the object is. If you're accessing it
via a pointer, GCC may not optimize the multiple bitfield tests as
much. Also, before egcs 1.1.2 (or the modified egcs 1.1.1 in the 1.4
release), there were many cases where it did the bitfield combinations
incorrectly and generated bogus code.
Beware of lurking dragons. B-)