diff options
author | Joseph Myers <joseph@codesourcery.com> | 2020-07-10 21:35:51 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2020-07-10 21:35:51 +0000 |
commit | b2104239c8f23ff3463dba64f1c9266896ce4fae (patch) | |
tree | 4177a3e3664db3169d964d1a98cda4eeefca6d39 /gcc/glimits.h | |
parent | ed1d3639e42dccc9372f11c6231c3ffe0589fd1c (diff) | |
download | gcc-b2104239c8f23ff3463dba64f1c9266896ce4fae.zip gcc-b2104239c8f23ff3463dba64f1c9266896ce4fae.tar.gz gcc-b2104239c8f23ff3463dba64f1c9266896ce4fae.tar.bz2 |
c: Add C2X BOOL_MAX and BOOL_WIDTH to limits.h
C2X adds BOOL_MAX and BOOL_WIDTH macros to <limits.h>. As GCC only
supports values 0 and 1 for _Bool (regardless of the number of bits in
the representation, other bits are padding bits and if any of them are
nonzero, the representation is a trap representation), the values of
those macros can just be hardcoded directly in <limits.h> rather than
needing corresponding predefined macros.
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc/
* glimits.h [__STDC_VERSION__ > 201710L] (BOOL_MAX, BOOL_WIDTH):
New macros.
gcc/testsuite/
* gcc.dg/c11-bool-limits-1.c, gcc.dg/c2x-bool-limits-1.c: New
tests.
Diffstat (limited to 'gcc/glimits.h')
-rw-r--r-- | gcc/glimits.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/gcc/glimits.h b/gcc/glimits.h index a37f496..5092751 100644 --- a/gcc/glimits.h +++ b/gcc/glimits.h @@ -150,4 +150,12 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see # define ULLONG_WIDTH __LONG_LONG_WIDTH__ #endif +#if defined (__STDC_VERSION__) && __STDC_VERSION__ > 201710L +/* C2X width and limit of _Bool. */ +# undef BOOL_MAX +# define BOOL_MAX 1 +# undef BOOL_WIDTH +# define BOOL_WIDTH 1 +#endif + #endif /* _LIMITS_H___ */ |