Re: [PATCH 2/2] netdev: octeon_mgmt: Fix structure layout for little-endian.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux