Re: __LITTLE_ENDIAN vs. __LITTLE_ENDIAN_BITFIELD

From: Benjamin Herrenschmidt
Date: Fri Oct 05 2007 - 19:28:17 EST



On Fri, 2007-10-05 at 15:37 -0500, Timur Tabi wrote:
> linux-os (Dick Johnson) wrote:
>
> > It makes no sense because a bitfield is something having to
> > do with a 'C' compiler and it must NEVER be used as a template
> > to address hardware! 'C' gives no guarantee of the ordering
> > within machine words. The only way you can access them is
> > using 'C'. They don't have addresses like other objects
> > (of course they do exist --somewhere). They are put into
> > "storage units," according to the standard, and these
> > storage units are otherwise undefined although you can
> > align them (don't go there).
>
> Well, if it doesn't make any sense why do we have __LITTLE_ENDIAN_BITFIELD and
> __BIG_ENDIAN_BITFIELD? That is, why do we do this:

.../... (snipped horror use of bitfields)

Bitfields are wrong. Period. Don't use them.

__LITTLE_ENDIAN_BITFIELD vs. __BIG_ENDIAN_BITFIELD is Linux way to cope
with existing code using them that needs fixing on architectures that
have C bitfields in reverse order but that's not even something that can
be properly relied upon generally.

Just don't use bitfields and be happy.

Ben.


-
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/