* doc/posix-headers/limits.texi (limits.h): Document them. * lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x. (BOOL_MAX, BOOL_WIDTH): New macros, from C2x. * m4/limits-h.m4 (gl_LIMITS_H): Also check BOOL_WIDTH. --- ChangeLog | 8 ++++++++ doc/posix-headers/limits.texi | 4 ++++ lib/limits.in.h | 16 +++++++++++++--- m4/limits-h.m4 | 3 ++- 4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog index d8a9bb1b8..dbf648571 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2021-07-30 Paul Eggert <egg...@cs.ucla.edu> + + limits-h: add BOOL_MAX, BOOL_WIDTH + * doc/posix-headers/limits.texi (limits.h): Document them. + * lib/limits.in.h: Also define CHAR_WIDTH etc. if C2x. + (BOOL_MAX, BOOL_WIDTH): New macros, from C2x. + * m4/limits-h.m4 (gl_LIMITS_H): Also check BOOL_WIDTH. + 2021-07-28 Simon Josefsson <si...@josefsson.org> maintainer-makefile: Respect cfg.mk setting announcement_Cc_, diff --git a/doc/posix-headers/limits.texi b/doc/posix-headers/limits.texi index edfc71619..22dc4239f 100644 --- a/doc/posix-headers/limits.texi +++ b/doc/posix-headers/limits.texi @@ -17,6 +17,10 @@ glibc 2.11 without @code{-D_GNU_SOURCE}, Cygwin, mingw, MSVC 14. @item Macros like @code{CHAR_WIDTH} are not defined on some platforms: glibc 2.24, NetBSD 9.0, many others. +@item +The macros @code{BOOL_MAX} and @code{BOOL_WIDTH} are not defined on +some platforms: +glibc 2.32, many others. @end itemize Portability problems fixed by Gnulib module @code{gethostname}: diff --git a/lib/limits.in.h b/lib/limits.in.h index 65ea12dbc..2ecafebb0 100644 --- a/lib/limits.in.h +++ b/lib/limits.in.h @@ -99,10 +99,11 @@ # endif #endif -/* Macros specified by ISO/IEC TS 18661-1:2014. */ +/* Macros specified by C2x and by ISO/IEC TS 18661-1:2014. */ #if (! defined ULLONG_WIDTH \ - && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__)) + && (defined _GNU_SOURCE || defined __STDC_WANT_IEC_60559_BFP_EXT__ \ + || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) # define CHAR_WIDTH _GL_INTEGER_WIDTH (CHAR_MIN, CHAR_MAX) # define SCHAR_WIDTH _GL_INTEGER_WIDTH (SCHAR_MIN, SCHAR_MAX) # define UCHAR_WIDTH _GL_INTEGER_WIDTH (0, UCHAR_MAX) @@ -114,7 +115,16 @@ # define ULONG_WIDTH _GL_INTEGER_WIDTH (0, ULONG_MAX) # define LLONG_WIDTH _GL_INTEGER_WIDTH (LLONG_MIN, LLONG_MAX) # define ULLONG_WIDTH _GL_INTEGER_WIDTH (0, ULLONG_MAX) -#endif /* !ULLONG_WIDTH && (_GNU_SOURCE || __STDC_WANT_IEC_60559_BFP_EXT__) */ +#endif + +/* Macros specified by C2x. */ + +#if (! defined BOOL_WIDTH \ + && (defined _GNU_SOURCE \ + || (defined __STDC_VERSION__ && 201710 < __STDC_VERSION__))) +# define BOOL_MAX 1 +# define BOOL_WIDTH 1 +#endif #endif /* _@GUARD_PREFIX@_LIMITS_H */ #endif /* _@GUARD_PREFIX@_LIMITS_H */ diff --git a/m4/limits-h.m4 b/m4/limits-h.m4 index 70dbb7dcf..00c9fe9e5 100644 --- a/m4/limits-h.m4 +++ b/m4/limits-h.m4 @@ -11,7 +11,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H], [ gl_CHECK_NEXT_HEADERS([limits.h]) - AC_CACHE_CHECK([whether limits.h has LLONG_MAX, WORD_BIT, ULLONG_WIDTH etc.], + AC_CACHE_CHECK([whether limits.h has WORD_BIT, BOOL_WIDTH etc.], [gl_cv_header_limits_width], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( @@ -22,6 +22,7 @@ AC_DEFUN_ONCE([gl_LIMITS_H], long long llm = LLONG_MAX; int wb = WORD_BIT; int ullw = ULLONG_WIDTH; + int bw = BOOL_WIDTH; ]])], [gl_cv_header_limits_width=yes], [gl_cv_header_limits_width=no])]) -- 2.31.1