lkml.org 
[lkml]   [2008]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch] Add helper macros for little-endian bitfields


On Wed, 27 Aug 2008, David Vrabel wrote:
>
> But why is this worthy of a crispy flaming? I've not seen anything
> definite beyond a somewhat vague 'some compilers don't optimize
> bitfields very well'.

Actually, it's not that compilers often optimize bitfields really badly.

It's also that bitfields are a total f*cking disaster when it comes to
endianness. As you found out.

Bitfields are fine if you don't actually care about the underlying format,
and want gcc to just randomly assign bits, and want things to be
convenient in that situation.

But _if_ you care about the underlying format, then inevitably the
bitfield costs will be much higher than just using bit operations on a
"u32" or similar. Your helper macros are horrible compared to just making
the bits work out right to begin with, and using the standard byte order
things.

Linus


\
 
 \ /
  Last update: 2008-08-27 23:29    [W:0.049 / U:1.484 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site