This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

changing struct bitfield allocation ?


GCC currently allocates bits for bitfields starting at the lowest
addressed byte of the bytes allocated to the type (i.e. the LSB for
little endian, MSB for big endian, but I need them to be allocated
from the MSB always, at least if the structure has a certain attribute
set.

I.e., given this structure:

struct foo {
  int a:9;
  int b:7;
  int c:6;
  int d:2;
} foo;

GCC currently allocates like this for little endian systems:

bits a 76543210 -------8 -------- --------
bits b -------- 6543210- -------- --------
bits c -------- -------- --543210 --------
bits d -------- -------- 10------ --------

But I need it to conditionally allocate like this:

bits a -------- -------- 0------- 87654321
bits b -------- -------- -6543210 --------
bits c -------- 543210-- -------- --------
bits d -------- ------10 -------- --------

BYTES_BIG_ENDIAN looked promising, but that changed pretty much
everything in the compiler to be the other endianness.  I need to
change just the bitfield allocations.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]