about summary refs log tree commit diff
path: root/stdlib/inttypes.h
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2023-03-14 16:58:35 +0000
committerJoseph Myers <joseph@codesourcery.com>2023-03-14 16:58:35 +0000
commit2d4728e60621c8844ec679291aa5458c622d8f4f (patch)
tree67fc945e60ec333a3c423ee634e5f5d242402824 /stdlib/inttypes.h
parent447273e0bf22a3d42e05e6b16d309f3f89879bea (diff)
downloadglibc-2d4728e60621c8844ec679291aa5458c622d8f4f.tar.gz
glibc-2d4728e60621c8844ec679291aa5458c622d8f4f.tar.xz
glibc-2d4728e60621c8844ec679291aa5458c622d8f4f.zip
Update printf %b/%B C2x support
WG14 recently accepted two additions to the printf/scanf %b/%B
support: there are now PRIb* and SCNb* macros in <inttypes.h>, and
printf %B is now an optional feature defined in normative text,
instead of recommended practice, with corresponding PRIB* macros that
can also be used to test whether that optional feature is supported.
See N3072 items 14 and 15 for details (those changes were accepted,
some other changes in that paper weren't).

Add the corresponding PRI* macros to glibc and update one place in the
manual referring to %B as recommended.  (SCNb* should naturally be
added at the same time as the corresponding scanf %b support.)

Tested for x86_64 and x86.
Diffstat (limited to 'stdlib/inttypes.h')
-rw-r--r--stdlib/inttypes.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/stdlib/inttypes.h b/stdlib/inttypes.h
index a5fa97b7c8..0ace21f54d 100644
--- a/stdlib/inttypes.h
+++ b/stdlib/inttypes.h
@@ -164,6 +164,45 @@ typedef wchar_t __gwchar_t;
 # define PRIxPTR	__PRIPTR_PREFIX "x"
 # define PRIXPTR	__PRIPTR_PREFIX "X"
 
+/* Binary notation.  */
+# if __GLIBC_USE (ISOC2X)
+#  define PRIb8		"b"
+#  define PRIb16	"b"
+#  define PRIb32	"b"
+#  define PRIb64	__PRI64_PREFIX "b"
+
+#  define PRIbLEAST8	"b"
+#  define PRIbLEAST16	"b"
+#  define PRIbLEAST32	"b"
+#  define PRIbLEAST64	__PRI64_PREFIX "b"
+
+#  define PRIbFAST8	"b"
+#  define PRIbFAST16	__PRIPTR_PREFIX "b"
+#  define PRIbFAST32	__PRIPTR_PREFIX "b"
+#  define PRIbFAST64	__PRI64_PREFIX "b"
+
+#  define PRIbMAX	__PRI64_PREFIX "b"
+#  define PRIbPTR	__PRIPTR_PREFIX "b"
+
+#  define PRIB8		"B"
+#  define PRIB16	"B"
+#  define PRIB32	"B"
+#  define PRIB64	__PRI64_PREFIX "B"
+
+#  define PRIBLEAST8	"B"
+#  define PRIBLEAST16	"B"
+#  define PRIBLEAST32	"B"
+#  define PRIBLEAST64	__PRI64_PREFIX "B"
+
+#  define PRIBFAST8	"B"
+#  define PRIBFAST16	__PRIPTR_PREFIX "B"
+#  define PRIBFAST32	__PRIPTR_PREFIX "B"
+#  define PRIBFAST64	__PRI64_PREFIX "B"
+
+#  define PRIBMAX	__PRI64_PREFIX "B"
+#  define PRIBPTR	__PRIPTR_PREFIX "B"
+# endif
+
 
 /* Macros for scanning format specifiers.  */