From: Paul Eggert <eggert@cs.ucla.edu>
To: bug-gnulib@gnu.org
Cc: Paul Eggert <eggert@cs.ucla.edu>
Subject: [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH
Date: Sat, 31 Jul 2021 12:01:18 -0700 [thread overview]
Message-ID: <20210731190124.279622-1-eggert@cs.ucla.edu> (raw)
* 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 ++++++++
| 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 <eggert@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 <simon@josefsson.org>
maintainer-makefile: Respect cfg.mk setting announcement_Cc_,
--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
next reply other threads:[~2021-07-31 19:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-31 19:01 Paul Eggert [this message]
2021-07-31 19:01 ` [PATCH 2/6] manywarnings: document GCC 11 warnings Paul Eggert
2021-07-31 19:01 ` [PATCH 3/6] gnulib-common: update for C2x 2020-12-11 draft Paul Eggert
2021-07-31 19:01 ` [PATCH 4/6] gnulib-common: update for gcc -Wmismatched-dealloc Paul Eggert
2021-07-31 19:01 ` [PATCH 5/6] xalloc: add malloc-related function attributes Paul Eggert
2021-07-31 19:01 ` [PATCH 6/6] doc: C2X -> C2x Paul Eggert
2021-08-01 13:38 ` [PATCH 1/6] limits-h: add BOOL_MAX, BOOL_WIDTH Bruno Haible
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210731190124.279622-1-eggert@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=bug-gnulib@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).