[PATCH] replace BITS_PER_UNIT with __CHAR_BIT__ in target libs

DJ Delorie dj@redhat.com
Fri Oct 30 17:19:00 GMT 2015


> $subject as far as I am aware these are the same on all supported targets.

The documentation for __CHAR_BIT__ says not to use it...

  @item __CHAR_BIT__
  Defined to the number of bits used in the representation of the
  @code{char} data type.  It exists to make the standard header given
  numerical limits work correctly.  You should not use
  this macro directly; instead, include the appropriate headers.

And the definition of BITS_PER_UNIT is more appropriate anyway:

  @item BITS_PER_UNIT
  The number of bits in an addressable storage unit (byte).  If you do
  not define this, the default is 8.

If a target had a sizeof(char) != 1, __CHAR_BIT__ and BITS_PER_UNIT
would be different, and IMHO BITS_PER_UNIT is the one we want to use
in the runtime, unless you're specifically talking about the "char"
type:

  cpp_define_formatted (pfile, "__CHAR_BIT__=%u",
                        TYPE_PRECISION (char_type_node));



More information about the Gcc-patches mailing list