On the lkml, I saw this post: Linus Torvalds <torvalds@osdl.org> writes: > On Wed, 18 Feb 2004, Benjamin Herrenschmidt wrote: >> >> Well... I still think it's asking for trouble in the long term >> to rely on them .... It's definitely broken for drivers of devices >> that can be used on different archs (PCI cards for example) since >> the layout of the bitfields is different at least with gcc between >> big and little endian machines. But I've also been bitten by >> alignement issues within the bitfield in the past (not with gcc >> though) and other funny things like that... > > I mostly agree. > > You _can_ get bitfields correct, but it takes some care. And btw, bit > endianness within a word does not necessarily match the byte endianness, > although they are usually connected. > > See for example <linux/tcp.h> for what you need to do to make bitfields > work right across architectures. > >> So overall, I just recommend to get rid of them. > > In general, yes. You can make bitfields be more readable, but you need to > be careful. And we all know how careful most driver writers tend to be. It's an interesting thread about bitfields. Does anyone know about the bit-endianness issue that Linus mentions? What implications does this issue have for kernel programming? -- --Ed L Cashin | PGP public key: ecashin@uga.edu | http://noserose.net/e/pgp/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/