This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
changing struct bitfield allocation ?
- From: DJ Delorie <dj at redhat dot com>
- To: gcc at gcc dot gnu dot org
- Date: Thu, 24 Jul 2003 20:48:23 -0400
- Subject: 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.