This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: BITS_PER_UNIT less than 8
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Ross Ridge <rridge at csclub dot uwaterloo dot ca>
- Cc: gcc at gcc dot gnu dot org
- Date: Sat, 8 Dec 2007 01:49:31 +0000 (UTC)
- Subject: Re: BITS_PER_UNIT less than 8
- References: <20071207203726.4690573D41@caffeine.csclub.uwaterloo.ca>
On Fri, 7 Dec 2007, Ross Ridge wrote:
> Boris Boesler writes:
> > Ok, so what have I to do to write a back-end where all addresses are
> > given in bits? Memory is addressed in bits, not bytes. So I set:
> >
> > #define BITS_PER_UNIT 1
> > #define UNITS_PER_WORD 32
>
> I don't know if it's useful to define the size of a byte to be less than
> 8-bits, even if that more accurately reflects the hardware. Standard C
> requires that the char type both be at least 8 bits (UCHAR_MAX >= 256)
> and the same size as a byte (sizeof(char) == 1). You can't define any
> types that are smaller than a char and have sizeof work correctly.
In theory GCC supports CHAR_TYPE_SIZE > BITS_PER_UNIT, so sizeof(char) is
still 1 (sizeof counts in units of CHAR_TYPE_SIZE not BITS_PER_UNIT) but a
char is not the hardware addressing unit. I expect this is even more
broken in practice than BITS_PER_UNIT > 8.
--
Joseph S. Myers
joseph@codesourcery.com