Re: [PATCH][2.6] IBM PowerPC Virtual Ethernet Driver

From: Linus Torvalds
Date: Wed Feb 18 2004 - 11:42:00 EST




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.

Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/