All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Vrabel <david.vrabel@csr.com>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Roland Dreier <rdreier@cisco.com>,
	Kernel development list <linux-kernel@vger.kernel.org>,
	linux-usb <linux-usb@vger.kernel.org>,
	torvalds@linux-foundation.org
Subject: Re: [patch] Add helper macros for little-endian bitfields
Date: Wed, 27 Aug 2008 16:20:54 +0100	[thread overview]
Message-ID: <48B570D6.7070301@csr.com> (raw)
In-Reply-To: <20080825014311.GS28946@ZenIV.linux.org.uk>

Al Viro wrote:
> On Sun, Aug 24, 2008 at 06:37:43PM -0700, Roland Dreier wrote:
>>  > + * NOTE: When using multibyte bitfields, you need to convert the data
>>  > + *       from Little Endian to CPU before you can access the bitfield
>>  > + *       (to make it simpler):
> 
> NOTE: When tempted to use multibyte bitfields on fixed-layout data, you
> need to look in the mirror, ask yourself "what will they do to me during
> code review for that?", shudder and decide that some temptations are
> just not worth the pain.

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'.

The structure definition and the DECL_BF_LEx() macros might be ugly but
the code using the structures is clearer.  For example,

    get_random_bytes(&tiebreaker, sizeof(unsigned));
    drp_ie->tiebreaker = tiebreaker & 1;

versus

    get_random_bytes(&tiebreaker, sizeof(unsigned));
    drp_ie->drp_control |= (tiebreaker & 1)
            ? UWB_DRP_IE_DRP_CTRL_TIEBREAKER : 0;

David
-- 
David Vrabel, Senior Software Engineer, Drivers
CSR, Churchill House, Cambridge Business Park,  Tel: +44 (0)1223 692562
Cowley Road, Cambridge, CB4 0WZ                 http://www.csr.com/

  reply	other threads:[~2008-08-27 15:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 13:17 New subsystems: Ultra-Wideband radio, Wireless USB and WiMedia LLC Protocol David Vrabel
2008-08-21 13:19 ` [patch] bitmap: add bitmap_copy_le() David Vrabel
2008-08-21 13:20 ` [patch] Add helper macros for little-endian bitfields David Vrabel
2008-08-25  1:37   ` Roland Dreier
2008-08-25  1:43     ` Al Viro
2008-08-27 15:20       ` David Vrabel [this message]
2008-08-27 21:19         ` Jeremy Fitzhardinge
2008-08-27 21:26         ` Linus Torvalds
2008-08-21 14:21 ` New subsystems: Ultra-Wideband radio, Wireless USB and WiMedia LLC Protocol Sam Ravnborg
2008-08-21 19:01   ` Sam Ravnborg
2008-08-21 15:43 ` Greg KH
2008-09-17 16:20 ` David Vrabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48B570D6.7070301@csr.com \
    --to=david.vrabel@csr.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rdreier@cisco.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.