From 2d4728e60621c8844ec679291aa5458c622d8f4f Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 14 Mar 2023 16:58:35 +0000 Subject: 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 , 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. --- stdlib/inttypes.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'stdlib') diff --git a/stdlib/inttypes.h b/stdlib/inttypes.h index a5fa97b..0ace21f 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. */ -- cgit v1.1