[lkml]   [2005]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH] 6700/6702PXH quirk
Jeff Garzik wrote:

> <pedantic>
> FWIW, compilers generate AWFUL code for bitfields. Bitfields are
> really tough to do optimally, whereas bit flags ["unsigned int flags &
> bitmask"] are the familiar ints and longs that the compiler is well
> tuned to optimize.

I wouldn't have chosen the micro-optimization argument against bitfields
because people who use them as booleans will be more than willing to
trade minuscule performance degredation in non-critical paths for
heaping piles of legibility:

if (!foo->enabled)
if (!(foo->flags & FOO_FLAG_ENABLED)

No, I would have chosen the maintenance risk of forgetting that they're
really 1 bit wide scalars which truncate on assignment.

struct foo {
unsigned enabled:1;

int some_thing_is_enabled(thing) {
return thing->whatever & some_high_bit;

foo->enabled = some_thing_is_enabled()

Requiring people to remember that they want !!() around assignments
seems much more dangerous. They'll get left out to "optimize" current
behaviour, leaving land mines in the tree for future maintainers.

- z
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-08-08 19:45    [W:3.545 / U:22.272 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site