[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20130627104048.GR7171@linux-mips.org>
Date: Thu, 27 Jun 2013 12:40:48 +0200
From: Ralf Baechle <ralf@...ux-mips.org>
To: David Laight <David.Laight@...LAB.COM>
Cc: David Daney <ddaney.cavm@...il.com>, netdev@...r.kernel.org,
"David S. Miller" <davem@...emloft.net>, linux-mips@...ux-mips.org,
David Daney <david.daney@...ium.com>
Subject: Re: [PATCH 2/2] netdev: octeon_mgmt: Fix structure layout for
little-endian.
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
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists