diff options
author | Joseph Myers <joseph@codesourcery.com> | 2016-09-09 17:59:43 +0100 |
---|---|---|
committer | Joseph Myers <jsm28@gcc.gnu.org> | 2016-09-09 17:59:43 +0100 |
commit | c65248cb7df48f125ff375849e2834d64e7bc3bd (patch) | |
tree | 203edf6dac268d0512d76ad0811fbc5af7098ad4 /gcc/doc | |
parent | ac376b15df246bc673b0e14074a4f19d39762480 (diff) | |
download | gcc-c65248cb7df48f125ff375849e2834d64e7bc3bd.zip gcc-c65248cb7df48f125ff375849e2834d64e7bc3bd.tar.gz gcc-c65248cb7df48f125ff375849e2834d64e7bc3bd.tar.bz2 |
Define TS 18661-1 type width macros in <limits.h> and <stdint.h>.
TS 18661-1 defines <limits.h> and <stdint.h> macros for widths of
standard integer types and the typedefs defined in, or whose limits
are defined in, <stdint.h>. (The connection to the main
floating-point subject matter of TS 18661-1 is that these are intended
to be used with the fromfp functions to convert from floating point to
integer types of any width in any rounding direction, though these
macros may be of more general use.)
This patch implements support for these macros in GCC's <limits.h> and
<stdint.h>. To avoid needing to implement fixincludes for system
headers where GCC wraps the system libc's <stdint.h> in hosted mode,
the test for the <stdint.h> macros uses -ffreestanding (I'll add the
macros to glibc's headers separately) - but as usual for new features
in these headers, platforms (primarily OpenBSD) that use USER_H to
avoid using GCC's headers at all will have failures until the system
headers have the feature added or appropriate fixincludes are
implemented.
The header macros are implemented using appropriate new predefined
macros, with the code avoiding defining more such macros than
necessary (so one predefined macro suffices for corresponding signed
and unsigned types, while no such predefined macros are needed for the
exact-width types such as int8_t).
Bootstrapped with no regressions on x86_64-pc-linux-gnu.
gcc:
* doc/cpp.texi (__SCHAR_WIDTH__, __SHRT_WIDTH__, __INT_WIDTH__)
(__LONG_WIDTH__, __LONG_LONG_WIDTH__, __PTRDIFF_WIDTH__)
(__SIG_ATOMIC_WIDTH__, __SIZE_WIDTH__, __WCHAR_WIDTH__)
(__WINT_WIDTH__, __INT_LEAST8_WIDTH__, __INT_LEAST16_WIDTH__)
(__INT_LEAST32_WIDTH__, __INT_LEAST64_WIDTH__)
(__INT_FAST8_WIDTH__, __INT_FAST16_WIDTH__, __INT_FAST32_WIDTH__)
(__INT_FAST64_WIDTH__, __INTPTR_WIDTH__, __INTMAX_WIDTH__):
Document.
* ginclude/stdint-gcc.h [__STDC_WANT_IEC_60559_BFP_EXT__]: Define
width macros from TS 18661-1.
* glimits.h [__STDC_WANT_IEC_60559_BFP_EXT__]: Likewise.
gcc/c-family:
* c-cppbuiltin.c (builtin_define_type_width): New function.
(builtin_define_stdint_macros, c_cpp_builtins): Define type width
macros.
gcc/testsuite:
* gcc.dg/limits-width-1.c, gcc.dg/stdint-width-1.c: New tests.
From-SVN: r240048
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/cpp.texi | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi index 44f59bd..bd89a0e 100644 --- a/gcc/doc/cpp.texi +++ b/gcc/doc/cpp.texi @@ -2247,6 +2247,33 @@ these macros directly; instead, include the appropriate headers. Some of these macros may not be defined on particular systems if GCC does not provide a @file{stdint.h} header on those systems. +@item __SCHAR_WIDTH__ +@itemx __SHRT_WIDTH__ +@itemx __INT_WIDTH__ +@itemx __LONG_WIDTH__ +@itemx __LONG_LONG_WIDTH__ +@itemx __PTRDIFF_WIDTH__ +@itemx __SIG_ATOMIC_WIDTH__ +@itemx __SIZE_WIDTH__ +@itemx __WCHAR_WIDTH__ +@itemx __WINT_WIDTH__ +@itemx __INT_LEAST8_WIDTH__ +@itemx __INT_LEAST16_WIDTH__ +@itemx __INT_LEAST32_WIDTH__ +@itemx __INT_LEAST64_WIDTH__ +@itemx __INT_FAST8_WIDTH__ +@itemx __INT_FAST16_WIDTH__ +@itemx __INT_FAST32_WIDTH__ +@itemx __INT_FAST64_WIDTH__ +@itemx __INTPTR_WIDTH__ +@itemx __INTMAX_WIDTH__ +Defined to the widths of the corresponding types. They exist to make +the implementations of @file{limits.h} and @file{stdint.h} make +correctly. You should not use these macros directly; instead, include +the appropriate headers. Some of these macros may not be defined on +particular systems if GCC does not provide a @file{stdint.h} header on +those systems. + @item __SIZEOF_INT__ @itemx __SIZEOF_LONG__ @itemx __SIZEOF_LONG_LONG__ |