netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: David Laight <David.Laight@ACULAB.COM>
Cc: David Daney <ddaney.cavm@gmail.com>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	linux-mips@linux-mips.org, David Daney <david.daney@cavium.com>
Subject: Re: [PATCH 2/2] netdev: octeon_mgmt: Fix structure layout for little-endian.
Date: Thu, 27 Jun 2013 12:40:48 +0200	[thread overview]
Message-ID: <20130627104048.GR7171@linux-mips.org> (raw)
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B729B@saturn3.aculab.com>

On Thu, Jun 20, 2013 at 10:47:57AM +0100, David Laight wrote:

> > The C ABI reverses the bitfield fill order when compiled as
> > little-endian.
> 
> No - it is completely implementation defined.
> The general concensus is not to use bitfields if you
> care at all about the bit assignments.

FWIW, bitfields often alow things to be expressed more nicely.  Just the
endian-dependent definition suck, so I came up with this little hack
for arch/mips/include/uapi/asm/inst.h:

#ifdef __MIPSEB__
#define BITFIELD_FIELD(field, more)                                     \
        field;                                                          \
        more

#elif defined(__MIPSEL__)

#define BITFIELD_FIELD(field, more)                                     \
        more                                                            \
        field;
#endif

struct i_format {                       /* signed immediate format */
        BITFIELD_FIELD(unsigned int opcode : 6,
        BITFIELD_FIELD(unsigned int rs : 5,
        BITFIELD_FIELD(unsigned int rt : 5,
        BITFIELD_FIELD(signed int simmediate : 16,
        ;))))
};

  Ralf

  reply	other threads:[~2013-06-27 10:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20  0:40 [PATCH 0/2] netdev: octeon_mgmt minor fixes David Daney
2013-06-20  0:40 ` [PATCH 1/2] netdev: octeon_mgmt: Correct tx IFG workaround David Daney
2013-06-20  1:08   ` Joe Perches
2013-06-20  1:28     ` David Daney
2013-06-20  1:37       ` Joe Perches
2013-06-20  1:47         ` David Daney
2013-06-20  0:40 ` [PATCH 2/2] netdev: octeon_mgmt: Fix structure layout for little-endian David Daney
2013-06-20  9:47   ` David Laight
2013-06-27 10:40     ` Ralf Baechle [this message]
2013-06-20  5:13 ` [PATCH 0/2] netdev: octeon_mgmt minor fixes David Miller

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=20130627104048.GR7171@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=David.Laight@ACULAB.COM \
    --cc=davem@davemloft.net \
    --cc=david.daney@cavium.com \
    --cc=ddaney.cavm@gmail.com \
    --cc=linux-mips@linux-mips.org \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).