lkml.org 
[lkml]   [2004]   [Feb]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH][2.6] IBM PowerPC Virtual Ethernet Driver
Keith Owens <kaos@ocs.com.au> wrote:
>
> On Wed, 18 Feb 2004 11:45:20 +1100,
> Benjamin Herrenschmidt <benh@kernel.crashing.org> wrote:
> >BITFIELDS ARE EVIL !!!
> >The compiler is perfectly free, afaik, to re-order them
>
> Not it is not. C standard (ISO/IEC 9899:1999 (E)), section 6.7.2.1.
>
> 10 ... If enough space remains, a bit-field that immediately follows
> another bit-field in a structure shall be packed into adjacent bits
> of the same unit. ...
>
> 13 Within a structure object, the non-bit-field members and the units
> in which bit-fields reside have addresses that increase in the order
> in which they are declared. ...
>
> There is no scope for a compiler to reorder the members or the bit
> fields of a structure.

Problem is portability between different architectures, especially little
endian versus big endian. The 3c59x driver used to use a bitfield to
represent hardware registers and had some lovely ifdeffery to make it work
on ppc hardware.

It's safe enough in arch-specific code but one may as well use the same
idioms as are used in generic code.

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

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:2.196 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site