changing struct bitfield allocation ?

DJ Delorie dj@redhat.com
Fri Jul 25 03:01:00 GMT 2003


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.



More information about the Gcc mailing list